VirtualBox

Ignore:
Timestamp:
Oct 28, 2015 8:17:18 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
103761
Message:

EFI/Firmware: 'svn merge /vendor/edk2/UDK2010.SR1 /vendor/edk2/current .', reverting and removing files+dirs listed in ReadMe.vbox, resolving conflicts with help from ../UDK2014.SP1/. This is a raw untested merge.

Location:
trunk/src/VBox/Devices/EFI/Firmware
Files:
113 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/Firmware

  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Application/IfConfig6/IfConfig6.c

    r48674 r58459  
    22  The implementation for Shell application IfConfig6.
    33
    4   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    137137  Str     = (CHAR16 *) AllocateZeroPool (StrSize (String));
    138138  ASSERT (Str != NULL);
    139   Str     = StrCpy (Str, String);
     139  Str     = StrnCpy (Str, String, StrLen (String));
    140140  ArgStr  = Str;
    141141
     
    366366  UINT8                            AddrCnt;
    367367
     368  Prefix   = 0;
    368369  AddrCnt  = 0;
    369370  *BufSize = 0;
     
    17201721      ASSERT (Str != NULL);
    17211722
    1722       Str             = StrCpy (Str, ValueStr);
     1723      Str             = StrnCpy (Str, ValueStr, StrLen (ValueStr));
    17231724      Private->IfName = Str;
    17241725    }
     
    17341735      ASSERT (Str != NULL);
    17351736
    1736       Str             = StrCpy (Str, ValueStr);
     1737      Str             = StrnCpy (Str, ValueStr, StrLen (ValueStr));
    17371738      Private->IfName = Str;
    17381739    }
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Application/IfConfig6/IfConfig6.inf

    r48674 r58459  
    11## @file
    2 Component description file for Shell application IfConfig6.
     2Shell application IfConfig6.
    33#
    4 #  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     4#  It is shell application which is used to set and get configurations for the
     5#  EFI IPv6 network stack.
     6#
     7#  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    58#
    69#  This program and the accompanying materials
     
    2124  VERSION_STRING                 = 1.0
    2225  ENTRY_POINT                    = IfConfig6Initialize
     26  MODULE_UNI_FILE                = IfConfig6.uni
    2327
    2428#
     
    4953
    5054[Protocols]
    51   gEfiIp6ServiceBindingProtocolGuid             ## CONSUMS
    52   gEfiIp6ConfigProtocolGuid                     ## CONSUMS
     55  gEfiIp6ServiceBindingProtocolGuid             ## CONSUMES
     56  gEfiIp6ConfigProtocolGuid                     ## CONSUMES
     57
     58[UserExtensions.TianoCore."ExtraFiles"]
     59  IfConfig6Extra.uni
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Application/IpsecConfig/Indexer.c

    r48674 r58459  
    22  The implementation of construct ENTRY_INDEXER in IpSecConfig application.
    33
    4   Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    235235
    236236      Indexer->PadId.PeerIdValid = TRUE;
     237      ZeroMem (Indexer->PadId.Id.PeerId, MAX_PEERID_LEN);
    237238      StrnCpy ((CHAR16 *) Indexer->PadId.Id.PeerId, ValueStr, ARRAY_SIZE (Indexer->PadId.Id.PeerId) - 1);
    238239    }
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Application/IpsecConfig/IpSecConfig.inf

    r48674 r58459  
    11## @file
    2 #  Component description file for IpSecConfig6 application.
     2#  Shell application IpSecConfig.
     3
     4#  This application is used to set and retrieve security and policy related information
     5#  for the EFI IPsec protocol driver.
    36#
    4 #  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     7#  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    58#
    69#  This program and the accompanying materials
     
    2124  VERSION_STRING                 = 1.0
    2225  ENTRY_POINT                    = InitializeIpSecConfig
     26  MODULE_UNI_FILE                = IpSecConfig.uni
    2327
    2428[Sources]
     
    5862
    5963[Protocols]
    60   gEfiIpSec2ProtocolGuid                        ##CONSUMS
    61   gEfiIpSecConfigProtocolGuid                   ##CONSUMS
     64  gEfiIpSec2ProtocolGuid                        ##CONSUMES
     65  gEfiIpSecConfigProtocolGuid                   ##CONSUMES
     66
     67[UserExtensions.TianoCore."ExtraFiles"]
     68  IpSecConfigExtra.uni
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Application/Ping6/Ping6.c

    r48674 r58459  
    22  The implementation for Ping6 application.
    33
    4   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    803803
    804804/**
    805   Destory the IP6 instance.
     805  Destroy the IP6 instance.
    806806
    807807  @param[in]    Private    The pointer of PING6_PRIVATE_DATA.
     
    809809**/
    810810VOID
    811 Ping6DestoryIp6Instance (
     811Ping6DestroyIp6Instance (
    812812  IN PING6_PRIVATE_DATA    *Private
    813813  )
     
    10201020
    10211021    if (Private->Ip6ChildHandle != NULL) {
    1022       Ping6DestoryIp6Instance (Private);
     1022      Ping6DestroyIp6Instance (Private);
    10231023    }
    10241024
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Application/Ping6/Ping6.inf

    r48674 r58459  
    11## @file
    2 Component description file for Ping6 application.
     2Shell application Ping6.
    33#
    4 #  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     4#  It is an shell application which is used to Ping the target host with IPv6 stack.
     5#
     6#  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    57#
    68#  This program and the accompanying materials
     
    2123  VERSION_STRING                 = 1.0
    2224  ENTRY_POINT                    = InitializePing6
     25  MODULE_UNI_FILE                = Ping6.uni
    2326
    2427#
     
    5962
    6063[Protocols]
    61   gEfiCpuArchProtocolGuid                       ## CONSUMS
    62   gEfiIp6ProtocolGuid                           ## CONSUMS
    63   gEfiIp6ServiceBindingProtocolGuid             ## CONSUMS
    64   gEfiIp6ConfigProtocolGuid                     ## CONSUMS
     64  gEfiCpuArchProtocolGuid                       ## CONSUMES
     65  gEfiIp6ProtocolGuid                           ## CONSUMES
     66  gEfiIp6ServiceBindingProtocolGuid             ## CONSUMES
     67  gEfiIp6ConfigProtocolGuid                     ## CONSUMES
     68
     69[UserExtensions.TianoCore."ExtraFiles"]
     70  Ping6Extra.uni
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Application/VConfig/VConfig.c

    r48674 r58459  
    22  Shell application for VLAN configuration.
    33
    4   Copyright (C) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Application/VConfig/VConfig.inf

    r48674 r58459  
    11## @file
    2 Component files for VLAN configuration shell application.
     2Shell application VLAN configuration.
    33#
    4 #  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     4#  It is shell application which is used to get and set VLAN configuration.
     5#
     6#  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    57#
    68#  This program and the accompanying materials
     
    2123  VERSION_STRING                 = 1.0
    2224  ENTRY_POINT                    = VlanConfigMain
     25  MODULE_UNI_FILE                = VConfig.uni
    2326
    2427#
     
    4548
    4649[Protocols]
    47   gEfiVlanConfigProtocolGuid
     50  gEfiVlanConfigProtocolGuid     ## CONSUMES
     51
     52[UserExtensions.TianoCore."ExtraFiles"]
     53  VConfigExtra.uni
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Dhcp6Dxe/ComponentName.c

    r48674 r58459  
    22  UEFI Component Name(2) protocol implementation for Dhcp6 driver.
    33
    4   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    173173};
    174174
     175GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE   *gDhcp6ControllerNameTable = NULL;
     176
     177CHAR16 *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};
    175188
    176189/**
     
    230243}
    231244
     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**/
     255EFI_STATUS
     256UpdateName (
     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}
    232309
    233310/**
     
    309386  )
    310387{
    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           );
    312440}
     441
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c

    r48674 r58459  
    33  implementationfor for Dhcp6 Driver.
    44
    5   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     5  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    66
    77  This program and the accompanying materials
     
    3232};
    3333
    34 
    3534/**
    3635  Configure the default Udp6Io to receive all the DHCP6 traffic
     
    8382
    8483/**
    85   Destory the Dhcp6 service. The Dhcp6 service may be partly initialized,
     84  Destroy the Dhcp6 service. The Dhcp6 service may be partly initialized,
    8685  or partly destroyed. If a resource is destroyed, it is marked as such in
    8786  case the destroy failed and being called again later.
     
    9695{
    9796  //
    98   // All children instances should have been already destoryed here.
     97  // All children instances should have been already destroyed here.
    9998  //
    10099  ASSERT (Service->NumOfChild == 0);
     
    133132{
    134133  DHCP6_SERVICE             *Dhcp6Srv;
     134  EFI_STATUS                Status;
    135135
    136136  *Service = NULL;
     
    155155  //
    156156  Dhcp6Srv->Signature       = DHCP6_SERVICE_SIGNATURE;
    157   Dhcp6Srv->InDestory       = FALSE;
    158157  Dhcp6Srv->Controller      = Controller;
    159158  Dhcp6Srv->Image           = ImageHandle;
     
    165164    sizeof (EFI_SERVICE_BINDING_PROTOCOL)
    166165    );
     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  }
    167179
    168180  //
     
    281293  Dhcp6Ins->UdpSts          = EFI_ALREADY_STARTED;
    282294  Dhcp6Ins->Service         = Service;
    283   Dhcp6Ins->InDestory       = FALSE;
     295  Dhcp6Ins->InDestroy       = FALSE;
    284296  Dhcp6Ins->MediaPresent    = TRUE;
    285297
     
    313325
    314326  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**/
     339EFI_STATUS
     340EFIAPI
     341Dhcp6DestroyChildEntry (
     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);
    315357}
    316358
     
    485527{
    486528  EFI_STATUS                       Status;
    487   EFI_TPL                          OldTpl;
    488529  EFI_HANDLE                       NicHandle;
    489530  EFI_SERVICE_BINDING_PROTOCOL     *ServiceBinding;
    490531  DHCP6_SERVICE                    *Service;
    491   DHCP6_INSTANCE                   *Instance;
     532  LIST_ENTRY                       *List;
     533  UINTN                            ListLength;
    492534
    493535  //
     
    497539
    498540  if (NicHandle == NULL) {
    499     return EFI_DEVICE_ERROR;
     541    return EFI_SUCCESS;
    500542  }
    501543
     
    514556
    515557  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)) {
    524559    //
    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)) {
    526579    //
    527     Service->InDestory = TRUE;
    528 
     580    // Destroy the service itself if no child instance left.
     581    //
    529582    Status = gBS->UninstallProtocolInterface (
    530583                    NicHandle,
     
    532585                    ServiceBinding
    533586                    );
    534 
    535587    if (EFI_ERROR (Status)) {
    536       Service->InDestory = FALSE;
    537588      goto ON_EXIT;
    538589    }
    539590
    540591    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 
    558595ON_EXIT:
    559   gBS->RestoreTPL (OldTpl);
    560596  return Status;
    561597}
     
    734770  }
    735771
    736   if (Instance->InDestory) {
     772  if (Instance->InDestroy) {
    737773    return EFI_SUCCESS;
    738774  }
     
    740776  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
    741777
    742   Instance->InDestory = TRUE;
     778  Instance->InDestroy = TRUE;
    743779
    744780  Status = gBS->CloseProtocol (
     
    750786
    751787  if (EFI_ERROR (Status)) {
    752     Instance->InDestory = FALSE;
     788    Instance->InDestroy = FALSE;
    753789    gBS->RestoreTPL (OldTpl);
    754790    return Status;
     
    758794  // Uninstall the MTFTP6 protocol first to enable a top down destruction.
    759795  //
     796  gBS->RestoreTPL (OldTpl);
    760797  Status = gBS->UninstallProtocolInterface (
    761798                  ChildHandle,
     
    763800                  Dhcp6
    764801                  );
    765 
    766   if (EFI_ERROR (Status)) {
    767     Instance->InDestory = FALSE;
     802  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
     803  if (EFI_ERROR (Status)) {
     804    Instance->InDestroy = FALSE;
    768805    gBS->RestoreTPL (OldTpl);
    769806    return Status;
     
    776813  Service->NumOfChild--;
    777814
     815  gBS->RestoreTPL (OldTpl);
     816
    778817  Dhcp6DestroyInstance (Instance);
    779 
    780   gBS->RestoreTPL (OldTpl);
    781 
    782818  return EFI_SUCCESS;
    783819}
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Dhcp6Dxe/Dhcp6Driver.h

    r48674 r58459  
    33  declaration for Dhcp6 Driver.
    44
    5   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     5  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    66
    77  This program and the accompanying materials
     
    2222extern EFI_COMPONENT_NAME_PROTOCOL  gDhcp6ComponentName;
    2323extern EFI_COMPONENT_NAME2_PROTOCOL gDhcp6ComponentName2;
     24extern EFI_UNICODE_STRING_TABLE     *gDhcp6ControllerNameTable;
    2425
    2526/**
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Dhcp6Dxe/Dhcp6Dxe.inf

    r48674 r58459  
    11## @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.
    36#
    4 #  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     7#  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    58#
    69#  This program and the accompanying materials
     
    2225  ENTRY_POINT                    = Dhcp6DriverEntryPoint
    2326  UNLOAD_IMAGE                   = NetLibDefaultUnload
     27  MODULE_UNI_FILE                = Dhcp6Dxe.uni
     28
    2429#
    2530# The following information is for reference only and not required by the build tools.
     
    6368
    6469[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
    6975
     76[UserExtensions.TianoCore."ExtraFiles"]
     77  Dhcp6DxeExtra.uni
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.c

    r48674 r58459  
    22  This EFI_DHCP6_PROTOCOL interface implementation.
    33
    4   Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    105105
    106106  //
    107   // Need to clear initial time to make sure that elapsed-time
    108   // is set to 0 for first Solicit.
    109   //
    110   Instance->StartTime = 0;
    111 
    112   //
    113107  // Send the solicit message to start S.A.R.R process.
    114108  //
     
    201195
    202196  //
    203   // The instance has already been stopped.
     197  // No valid REPLY message received yet, cleanup this instance directly.
    204198  //
    205199  if (Instance->IaCb.Ia->State == Dhcp6Init ||
     
    207201      Instance->IaCb.Ia->State == Dhcp6Requesting
    208202      ) {
    209     return Status;
     203    goto ON_EXIT;
    210204  }
    211205
     
    216210
    217211  Instance->UdpSts = EFI_ALREADY_STARTED;
    218   Dhcp6SendReleaseMsg (Instance, Instance->IaCb.Ia);
    219 
     212  Status = Dhcp6SendReleaseMsg (Instance, Instance->IaCb.Ia);
    220213  gBS->RestoreTPL (OldTpl);
     214  if (EFI_ERROR (Status)) {
     215    goto ON_EXIT;
     216  }
    221217
    222218  //
     
    230226    Status = Instance->UdpSts;
    231227  }
    232 
     228 
     229ON_EXIT:
    233230  //
    234231  // Clean up the session data for the released Ia.
     
    605602{
    606603  EFI_STATUS                   Status;
    607   EFI_TPL                      OldTpl;
    608604  DHCP6_INSTANCE               *Instance;
    609605  DHCP6_SERVICE                *Service;
    610   DHCP6_INF_CB                 *InfCb;
    611606  UINTN                        Index;
     607  EFI_EVENT                    Timer;
     608  EFI_STATUS                   TimerStatus;
     609  UINTN                        GetMappingTimeOut;
    612610
    613611  if (This == NULL || OptionRequest == NULL || Retransmission == NULL || ReplyCallback == NULL) {
     
    634632  Service  = Instance->Service;
    635633
    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 (
    659635             Instance,
    660              InfCb,
    661636             SendClientId,
    662637             OptionRequest,
    663638             OptionCount,
    664639             OptionList,
    665              Retransmission
     640             Retransmission,
     641             TimeoutEvent,
     642             ReplyCallback,
     643             CallbackContext
    666644             );
    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  }
    668688  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  }
    687691
    688692  //
     
    698702
    699703  return EFI_SUCCESS;
    700 
    701 ON_ERROR:
    702 
    703   RemoveEntryList (&InfCb->Link);
    704   FreePool (InfCb);
    705   gBS->RestoreTPL (OldTpl);
    706 
    707   return Status;
    708704}
    709705
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h

    r48674 r58459  
    22  Dhcp6 internal data structure and definition declaration.
    33
    4   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    2222#include <Protocol/Dhcp6.h>
    2323#include <Protocol/Udp6.h>
     24#include <Protocol/Ip6Config.h>
    2425#include <Protocol/ServiceBinding.h>
    2526#include <Protocol/DriverBinding.h>
     
    3435#include <Library/BaseLib.h>
    3536#include <Library/NetLib.h>
     37#include <Library/PrintLib.h>
    3638
    3739
     
    245247  UINT8                         AdPref;
    246248  EFI_IPv6_ADDRESS              *Unicast;
    247   EFI_STATUS                    UdpSts;
    248   BOOLEAN                       InDestory;
     249  volatile EFI_STATUS           UdpSts;
     250  BOOLEAN                       InDestroy;
    249251  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  //
    250256  UINT64                        StartTime;
    251257};
     
    260266  EFI_SERVICE_BINDING_PROTOCOL  ServiceBinding;
    261267  EFI_SIMPLE_NETWORK_PROTOCOL   *Snp;
     268  EFI_IP6_CONFIG_PROTOCOL       *Ip6Cfg;
    262269  EFI_DHCP6_DUID                *ClientId;
    263270  UDP_IO                        *UdpIo;
     
    265272  LIST_ENTRY                    Child;
    266273  UINTN                         NumOfChild;
    267   BOOLEAN                       InDestory;
    268274};
    269275
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Dhcp6Dxe/Dhcp6Io.c

    r48674 r58459  
    22  Dhcp6 internal functions implementation.
    33
    4   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    5353
    5454  //
    55   // Save tx packet pointer, and it will be destoryed when reply received.
     55  // Save tx packet pointer, and it will be destroyed when reply received.
    5656  //
    5757  TxCb->TxPacket = Packet;
     
    364364}
    365365
     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**/
     376BOOLEAN
     377Dhcp6IsValidTxCb (
     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}
    366392
    367393/**
     
    594620    T1 = NTOHL (ReadUnaligned32 ((UINT32 *) (Option + 8)));
    595621    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    }
    596630    IaInnerOpt = Option + 16;
    597631    IaInnerLen = (UINT16) (NTOHS (ReadUnaligned16 ((UINT16 *) (Option + 2))) - 12);
     
    698732              );
    699733  if (*Option == NULL) {
    700     return EFI_DEVICE_ERROR;
     734    return EFI_SUCCESS;
    701735  }
    702736
     
    950984             Instance->IaCb.Ia,
    951985             Instance->IaCb.T1,
    952              Instance->IaCb.T2
     986             Instance->IaCb.T2,
     987             Packet->Dhcp6.Header.MessageType
    953988             );
    954989
     
    9881023  //
    9891024  Instance->IaCb.Ia->State = Dhcp6Selecting;
     1025  //
     1026  // Clear initial time for current transaction.
     1027  //
     1028  Instance->StartTime = 0;
    9901029
    9911030  Status = Dhcp6TransmitPacket (Instance, Packet, Elapsed);
     
    11341173             Instance->IaCb.Ia,
    11351174             Instance->IaCb.T1,
    1136              Instance->IaCb.T2
     1175             Instance->IaCb.T2,
     1176             Packet->Dhcp6.Header.MessageType
    11371177             );
    11381178
     
    11721212  //
    11731213  Instance->IaCb.Ia->State = Dhcp6Requesting;
     1214  //
     1215  // Clear initial time for current transaction.
     1216  //
     1217  Instance->StartTime = 0;
    11741218
    11751219  Status = Dhcp6TransmitPacket (Instance, Packet, Elapsed);
     
    12831327             );
    12841328
    1285   Cursor = Dhcp6AppendIaOption (Cursor, DecIa, 0, 0);
     1329  Cursor = Dhcp6AppendIaOption (Cursor, DecIa, 0, 0, Packet->Dhcp6.Header.MessageType);
    12861330
    12871331  //
     
    13061350  //
    13071351  Instance->IaCb.Ia->State = Dhcp6Declining;
     1352  //
     1353  // Clear initial time for current transaction.
     1354  //
     1355  Instance->StartTime = 0;
    13081356
    13091357  Status = Dhcp6TransmitPacket (Instance, Packet, Elapsed);
     
    14161464             );
    14171465
    1418   Cursor = Dhcp6AppendIaOption (Cursor, RelIa, 0, 0);
     1466  Cursor = Dhcp6AppendIaOption (Cursor, RelIa, 0, 0, Packet->Dhcp6.Header.MessageType);
    14191467
    14201468  //
     
    15411589             Instance->IaCb.Ia,
    15421590             Instance->IaCb.T1,
    1543              Instance->IaCb.T2
     1591             Instance->IaCb.T2,
     1592             Packet->Dhcp6.Header.MessageType
    15441593             );
    15451594
     
    16131662  Instance->IaCb.Ia->State = State;
    16141663  Instance->IaCb.LeaseTime = (RebindRequest) ? Instance->IaCb.T2 : Instance->IaCb.T1;
     1664  //
     1665  // Clear initial time for current transaction.
     1666  //
     1667  Instance->StartTime = 0;
    16151668
    16161669  Status = Dhcp6TransmitPacket (Instance, Packet, Elapsed);
     
    16271680}
    16281681
     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**/
     1703EFI_STATUS
     1704Dhcp6StartInfoRequest (
     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 
     1775ON_ERROR:
     1776  gBS->RestoreTPL (OldTpl);
     1777  RemoveEntryList (&InfCb->Link);
     1778  FreePool (InfCb);
     1779
     1780  return Status;
     1781}
    16291782
    16301783/**
     
    17451898  Packet->Length += (UINT32) (Cursor - Packet->Dhcp6.Option);
    17461899  ASSERT (Packet->Size > Packet->Length + 8);
     1900 
     1901  //
     1902  // Clear initial time for current transaction.
     1903  //
     1904  Instance->StartTime = 0;
    17471905
    17481906  //
     
    18422000             Instance->IaCb.Ia,
    18432001             Instance->IaCb.T1,
    1844              Instance->IaCb.T2
     2002             Instance->IaCb.T2,
     2003             Packet->Dhcp6.Header.MessageType
    18452004             );
    18462005
     
    18792038  //
    18802039  Instance->IaCb.Ia->State = Dhcp6Confirming;
     2040  //
     2041  // Clear initial time for current transaction.
     2042  //
     2043  Instance->StartTime = 0;
    18812044
    18822045  Status = Dhcp6TransmitPacket (Instance, Packet, Elapsed);
     
    19212084  ASSERT (Packet != NULL);
    19222085
     2086  Status = EFI_SUCCESS;
     2087
    19232088  if (Packet->Dhcp6.Header.MessageType != Dhcp6MsgReply) {
    19242089    return EFI_DEVICE_ERROR;
     
    19572122               );
    19582123    if (Option == NULL) {
    1959       return EFI_DEVICE_ERROR;
     2124      return EFI_SUCCESS;
    19602125    }
    19612126  }
     
    19652130  //
    19662131  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              FALSE
    1979              );
    19802132
    19812133  if (EFI_ERROR (Status)) {
     
    20162168    Instance->StartTime       = 0;
    20172169
    2018     return EFI_SUCCESS;
     2170    Status = EFI_SUCCESS;
     2171    goto ON_EXIT;
    20192172  }
    20202173
     
    20332186  if (!EFI_ERROR (Status)) {
    20342187    //
    2035     // Reset start time for next exchange.
    2036     //
    2037     Instance->StartTime       = 0;
    2038 
    2039     //
    20402188    // No status code or no error status code means succeed to reply.
    20412189    //
    20422190    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;
    20462241    }
    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   
    20842245  } else if (Option != NULL) {
    20852246    //
     
    21272288      break;
    21282289
     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
    21292303    default:
    21302304      //
     
    21362310
    21372311  return EFI_SUCCESS;
     2312 
     2313ON_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;
    21382324}
    21392325
     
    22792465  // See the details in the section-17.1.3 of rfc-3315.
    22802466  //
    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;
    22922474  }
    22932475
     
    24112593  Status   = EFI_SUCCESS;
    24122594
    2413   if (Instance->InDestory || Instance->Config == NULL) {
     2595  if (Instance->Config == NULL) {
    24142596    goto ON_CONTINUE;
    24152597  }
     
    25242706  IsMatched = FALSE;
    25252707  InfCb     = NULL;
    2526 
    2527   if (Instance->InDestory) {
    2528     goto ON_EXIT;
    2529   }
    25302708
    25312709  if (Packet->Dhcp6.Header.MessageType != Dhcp6MsgReply) {
     
    28303008          //
    28313009          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)) {
    28333013            TxCb->RetryCnt++;
    28343014          }
     
    28463026      //
    28473027      if (TxCb->RetryCtl.Mrc != 0 && TxCb->RetryCtl.Mrc < TxCb->RetryCnt) {
     3028        Status = EFI_NO_RESPONSE;
    28483029        goto ON_CLOSE;
    28493030      }
     
    28533034      //
    28543035      if (TxCb->RetryCtl.Mrd != 0 && TxCb->RetryCtl.Mrd <= TxCb->RetryLos) {
     3036        Status = EFI_NO_RESPONSE;
    28553037        goto ON_CLOSE;
    28563038      }
     
    29423124 ON_CLOSE:
    29433125
    2944   if (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgInfoRequest ||
     3126  if (Dhcp6IsValidTxCb (Instance, TxCb) &&
     3127      TxCb->TxPacket != NULL &&
     3128      (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgInfoRequest ||
    29453129      TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgRenew       ||
    2946       TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgConfirm
     3130      TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgConfirm)
    29473131      ) {
    29483132    //
     
    29693153    // The failure of the others will terminate current state machine if timeout.
    29703154    //
    2971     Dhcp6CleanupSession (Instance, EFI_NO_RESPONSE);
     3155    Dhcp6CleanupSession (Instance, Status);
    29723156  }
    29733157}
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Dhcp6Dxe/Dhcp6Io.h

    r48674 r58459  
    22  Dhcp6 internal functions declaration.
    33
    4   Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    128128  IN DHCP6_INSTANCE            *Instance,
    129129  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**/
     153EFI_STATUS
     154Dhcp6StartInfoRequest (
     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
    130164  );
    131165
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c

    r48674 r58459  
    22  Dhcp6 support functions implementation.
    33
    4   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    4242  // See details in section-9 of rfc-3315.
    4343  //
    44   Duid = GetVariable (L"ClientId", &gEfiDhcp6ServiceBindingProtocolGuid);
     44  GetVariable2 (L"ClientId", &gEfiDhcp6ServiceBindingProtocolGuid, (VOID**)&Duid, NULL);
    4545  if (Duid != NULL) {
    4646    return Duid;
     
    144144    // Set the Duid-type, hardware-type, time and copy the hardware address.
    145145    //
    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
    150150    CopyMem (Duid->Duid + 8, &Mode->CurrentAddress, Mode->HwAddressSize);
    151151  }
     
    158158                  (VOID *) Duid
    159159                  );
    160   ASSERT_EFI_ERROR (Status);
     160  if (EFI_ERROR (Status)) {
     161    FreePool (Duid);
     162    return NULL;
     163  }
    161164
    162165  return Duid;
     
    384387  )
    385388{
    386   EFI_DHCP6_IA_ADDRESS        *IaAddr;
    387389  UINT32                      MinLt;
    388390  UINT32                      MaxLt;
     
    399401  //
    400402  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);
    404405  }
    405406
     
    648649}
    649650
     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**/
     661UINT8 *
     662Dhcp6AppendIaAddrOption (
     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
    650720
    651721/**
     
    656726  @param[in]      T1            The time of T1.
    657727  @param[in]      T2            The time of T2.
     728  @param[in]      MessageType   Message type of DHCP6 package.
    658729
    659730  @return         Buf           The position to append the next Ia option.
     
    665736  IN     EFI_DHCP6_IA           *Ia,
    666737  IN     UINT32                 T1,
    667   IN     UINT32                 T2
     738  IN     UINT32                 T2,
     739  IN     UINT32                 MessageType
    668740  )
    669741{
     
    671743  UINT16                    *Len;
    672744  UINTN                     Index;
    673   UINT16                    Length;
    674745
    675746  //
     
    714785  //
    715786  if (Ia->Descriptor.Type == Dhcp6OptIana) {
    716     WriteUnaligned32 ((UINT32 *) Buf, ((T1 != 0) ? T1 : 0xffffffff));
     787    WriteUnaligned32 ((UINT32 *) Buf, HTONL ((T1 != 0) ? T1 : 0xffffffff));
    717788    Buf                   += 4;
    718     WriteUnaligned32 ((UINT32 *) Buf, ((T2 != 0) ? T2 : 0xffffffff));
     789    WriteUnaligned32 ((UINT32 *) Buf, HTONL ((T2 != 0) ? T2 : 0xffffffff));
    719790    Buf                   += 4;
    720791  }
     
    724795  //
    725796  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);
    735799  }
    736800
     
    828892  //
    829893  // 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 Solicit
     894  // sending and that we need to initialize the value.  First DHCP message
    831895  // gets 0 elapsed-time.  Otherwise, calculate based on StartTime.
    832896  //
     
    935999}
    9361000
     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**/
     1012BOOLEAN
     1013Dhcp6AddrIsInCurrentIa (
     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}
    9371029
    9381030/**
    9391031  Parse the address option and update the address infomation.
    9401032
     1033  @param[in]      CurrentIa     The pointer to the Ia Address in control blcok.
    9411034  @param[in]      IaInnerOpt    The pointer to the buffer.
    9421035  @param[in]      IaInnerLen    The length to parse.
     
    9471040VOID
    9481041Dhcp6ParseAddrOption (
     1042  IN     EFI_DHCP6_IA            *CurrentIa,
    9491043  IN     UINT8                   *IaInnerOpt,
    9501044  IN     UINT16                  IaInnerLen,
     
    9571051  UINT16                      OpCode;
    9581052  UINT32                      ValidLt;
     1053  UINT32                      PreferredLt;
     1054  EFI_DHCP6_IA_ADDRESS        *IaAddr;
    9591055
    9601056  //
     
    9931089  while (Cursor < IaInnerOpt + IaInnerLen) {
    9941090    //
    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.
    9961093    //
    9971094    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)) {
    10011100      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;
    10051104        AddrBuf = (EFI_DHCP6_IA_ADDRESS *) ((UINT8 *) AddrBuf + sizeof (EFI_DHCP6_IA_ADDRESS));
    10061105      }
    1007 
    10081106      (*AddrNum)++;
    10091107    }
     
    10261124  @retval     EFI_SUCCESS           Create an IA control block successfully.
    10271125  @retval     EFI_OUT_OF_RESOURCES  Required system resources could not be allocated.
     1126  @retval     EFI_DEVICE_ERROR      An unexpected error.
    10281127
    10291128**/
     
    10421141
    10431142  if (Instance->IaCb.Ia == NULL) {
    1044     return EFI_NOT_FOUND;
     1143    return EFI_DEVICE_ERROR;
    10451144  }
    10461145
     
    10491148  // the value 0 of valid lifetime.
    10501149  //
    1051   Dhcp6ParseAddrOption (IaInnerOpt, IaInnerLen, &AddrNum, NULL);
     1150  Dhcp6ParseAddrOption (Instance->IaCb.Ia, IaInnerOpt, IaInnerLen, &AddrNum, NULL);
    10521151
    10531152  if (AddrNum == 0) {
     
    10711170  Ia->IaAddressCount = AddrNum;
    10721171  CopyMem (&Ia->Descriptor, &Instance->Config->IaDescriptor, sizeof (EFI_DHCP6_IA_DESCRIPTOR));
    1073   Dhcp6ParseAddrOption (IaInnerOpt, IaInnerLen, &AddrNum, Ia->IaAddress);
     1172  Dhcp6ParseAddrOption (Instance->IaCb.Ia, IaInnerOpt, IaInnerLen, &AddrNum, Ia->IaAddress);
    10741173
    10751174  //
     
    11901289  }
    11911290}
     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**/
     1301EFI_STATUS
     1302Dhcp6GetMappingTimeOut (
     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  
    22  Dhcp6 support functions declaration.
    33
    4   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    1818
    1919
    20 #define  DHCP6_10_BIT_MASK     0x3ff
     20#define  DHCP6_10_BIT_MASK             0x3ff
     21#define  DHCP6_DAD_ADDITIONAL_DELAY    30000000 // 3 seconds
    2122
    2223/**
     
    192193  @param[in]      T1            The time of T1.
    193194  @param[in]      T2            The time of T2.
     195  @param[in]      MessageType   Message type of DHCP6 package.
    194196
    195197  @return         Buf           The position to append the next Ia option.
     
    201203  IN     EFI_DHCP6_IA           *Ia,
    202204  IN     UINT32                 T1,
    203   IN     UINT32                 T2
     205  IN     UINT32                 T2,
     206  IN     UINT32                 MessageType
    204207  );
    205208
     
    274277  Parse the address option and update the address info.
    275278
     279  @param[in]      CurrentIa     The pointer to the Ia Address in control blcok.
    276280  @param[in]      IaInnerOpt    The pointer to the buffer.
    277281  @param[in]      IaInnerLen    The length to parse.
     
    282286VOID
    283287Dhcp6ParseAddrOption (
     288  IN     EFI_DHCP6_IA            *CurrentIa,
    284289  IN     UINT8                   *IaInnerOpt,
    285290  IN     UINT16                  IaInnerLen,
     
    300305  @retval     EFI_SUCCESS           Create an IA control block successfully.
    301306  @retval     EFI_OUT_OF_RESOURCES  Required system resources could not be allocated.
     307  @retval     EFI_DEVICE_ERROR      An unexpected error.
    302308
    303309**/
     
    338344  );
    339345
     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**/
     355EFI_STATUS
     356Dhcp6GetMappingTimeOut (
     357  IN  EFI_IP6_CONFIG_PROTOCOL       *Ip6Cfg,
     358  OUT UINTN                         *TimeOut
     359  );
    340360#endif
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/IScsiDxe/ComponentName.c

    r48674 r58459  
    22  UEFI Component Name(2) protocol implementation for iSCSI.
    33
    4 Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    4343  }
    4444};
     45
     46GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE  *gIScsiControllerNameTable = NULL;
    4547
    4648/**
     
    101103
    102104/**
     105  Update the component name for the iSCSI instance.
     106
     107  @param[in]  IScsiExtScsiPassThru  A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
     108  @param[in]  Ipv6Flag              TRUE if IP6 network stack is used.
     109 
     110  @retval EFI_SUCCESS               Update the ControllerNameTable of this instance successfully.
     111  @retval EFI_INVALID_PARAMETER     The input parameter is invalid.
     112  @retval EFI_UNSUPPORTED           Can't get the corresponding NIC info from the Controller handle.
     113 
     114**/
     115EFI_STATUS
     116UpdateName (
     117  IN   EFI_EXT_SCSI_PASS_THRU_PROTOCOL *IScsiExtScsiPassThru,
     118  IN   BOOLEAN     Ipv6Flag
     119  )
     120{
     121  EFI_STATUS                       Status;
     122  CHAR16                           HandleName[80];
     123  ISCSI_DRIVER_DATA                *Private;
     124  UINT8                            NicIndex;
     125
     126  if (IScsiExtScsiPassThru == NULL) {
     127    return EFI_INVALID_PARAMETER;
     128  }
     129 
     130  Private  = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (IScsiExtScsiPassThru);
     131  NicIndex = Private->Session->ConfigData->NicIndex;
     132   
     133  UnicodeSPrint (
     134    HandleName,
     135    sizeof (HandleName),
     136    L"iSCSI (%s, NicIndex=%d)",
     137    Ipv6Flag ? L"IPv6" : L"IPv4",
     138    NicIndex
     139  );
     140
     141  if (gIScsiControllerNameTable != NULL) {
     142    FreeUnicodeStringTable (gIScsiControllerNameTable);
     143    gIScsiControllerNameTable = NULL;
     144  }
     145
     146  Status = AddUnicodeString2 (
     147             "eng",
     148             gIScsiComponentName.SupportedLanguages,
     149             &gIScsiControllerNameTable,
     150             HandleName,
     151             TRUE
     152             );
     153  if (EFI_ERROR (Status)) {
     154    return Status;
     155  }
     156
     157  return AddUnicodeString2 (
     158           "en",
     159           gIScsiComponentName2.SupportedLanguages,
     160           &gIScsiControllerNameTable,
     161           HandleName,
     162           FALSE
     163           );
     164}
     165
     166/**
    103167  Retrieves a Unicode string that is the user readable name of the controller
    104168  that is being managed by a driver.
     
    178242  )
    179243{
    180   return EFI_UNSUPPORTED;
     244  EFI_STATUS                      Status;
     245 
     246  EFI_HANDLE                      IScsiController;
     247  BOOLEAN                         Ipv6Flag;
     248  EFI_GUID                        *IScsiPrivateGuid;
     249  ISCSI_PRIVATE_PROTOCOL          *IScsiIdentifier;
     250 
     251  EFI_EXT_SCSI_PASS_THRU_PROTOCOL *IScsiExtScsiPassThru;
     252 
     253  if (ControllerHandle == NULL) {
     254    return EFI_UNSUPPORTED;
     255  }
     256
     257  //
     258  // Get the handle of the controller we are controling.
     259  //
     260  IScsiController = NetLibGetNicHandle (ControllerHandle, &gEfiTcp4ProtocolGuid);
     261  if (IScsiController != NULL) {
     262    IScsiPrivateGuid = &gIScsiV4PrivateGuid;
     263    Ipv6Flag = FALSE;
     264  } else {
     265    IScsiController = NetLibGetNicHandle (ControllerHandle, &gEfiTcp6ProtocolGuid);
     266    if (IScsiController != NULL) {
     267      IScsiPrivateGuid = &gIScsiV6PrivateGuid;
     268      Ipv6Flag = TRUE;
     269    } else {
     270      return EFI_UNSUPPORTED;
     271    }
     272  }
     273
     274  Status = gBS->OpenProtocol (
     275                  IScsiController,
     276                  IScsiPrivateGuid,
     277                  (VOID **) &IScsiIdentifier,
     278                  NULL,
     279                  NULL,
     280                  EFI_OPEN_PROTOCOL_GET_PROTOCOL
     281                  );
     282  if (EFI_ERROR (Status)) {
     283    return Status;
     284  }
     285
     286  if(ChildHandle != NULL) {
     287    if(!Ipv6Flag) {
     288      //
     289      // Make sure this driver produced ChildHandle
     290      //
     291      Status = EfiTestChildHandle (
     292                 ControllerHandle,
     293                 ChildHandle,
     294                 &gEfiTcp4ProtocolGuid
     295                 );
     296      if (EFI_ERROR (Status)) {
     297        return Status;
     298      }
     299    } else {
     300      //
     301      // Make sure this driver produced ChildHandle
     302      //
     303      Status = EfiTestChildHandle (
     304                 ControllerHandle,
     305                 ChildHandle,
     306                 &gEfiTcp6ProtocolGuid
     307                 );
     308      if (EFI_ERROR (Status)) {
     309        return Status;
     310      }
     311    }
     312   
     313    //
     314    // Retrieve an instance of a produced protocol from ChildHandle
     315    //
     316    Status = gBS->OpenProtocol (
     317                    ChildHandle,
     318                    &gEfiExtScsiPassThruProtocolGuid,
     319                   (VOID **)&IScsiExtScsiPassThru,
     320                    NULL,
     321                    NULL,
     322                    EFI_OPEN_PROTOCOL_GET_PROTOCOL
     323                    );
     324    if (EFI_ERROR (Status)) {
     325      return Status;
     326    }
     327   
     328    //
     329    // Update the component name for this child handle.
     330    //
     331    Status = UpdateName (IScsiExtScsiPassThru, Ipv6Flag);
     332    if (EFI_ERROR (Status)) {
     333      return Status;
     334    }
     335  }
     336
     337  return LookupUnicodeString2 (
     338           Language,
     339           This->SupportedLanguages,
     340           gIScsiControllerNameTable,
     341           ControllerName,
     342           (BOOLEAN)(This == &gIScsiComponentName)
     343           );
    181344}
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/IScsiDxe/IScsiConfig.c

    r48674 r58459  
    22  Helper functions for configuring or getting the parameters relating to iSCSI.
    33
    4 Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    785785                    L"AttemptOrder",
    786786                    &gIScsiConfigGuid,
    787                     EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
     787                    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,
    788788                    AttemptConfigOrderSize,
    789789                    AttemptConfigOrder
     
    12471247  }
    12481248
    1249   Attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS
    1250               | EFI_VARIABLE_NON_VOLATILE;
     1249  Attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE;
    12511250
    12521251  //
     
    15591558                  L"AttemptOrder",
    15601559                  &gIScsiConfigGuid,
    1561                   EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
     1560                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,
    15621561                  AttemptConfigOrderSize,
    15631562                  AttemptConfigOrderTmp
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/IScsiDxe/IScsiConfigNVDataStruc.h

    r48674 r58459  
    22  Define NVData structures used by the iSCSI configuration component.
    33
    4 Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    6969#define LUN_MAX_SIZE              20
    7070
    71 #define ISCSI_CHAP_UNI            1
    72 #define ISCSI_CHAP_MUTUAL         2
     71#define ISCSI_CHAP_UNI            0
     72#define ISCSI_CHAP_MUTUAL         1
    7373
    7474#define TARGET_PORT_MIN_NUM       0
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr

    r48674 r58459  
    8989      help   = STRING_TOKEN (STR_SAVE_AND_EXIT),
    9090      text   = STRING_TOKEN (STR_SAVE_AND_EXIT),
    91         text   = STRING_TOKEN (STR_SAVE_AND_EXIT),
    9291      flags  = INTERACTIVE,
    9392      key    = KEY_SAVE_ORDER_CHANGES;
     
    9695      help   = STRING_TOKEN (STR_NO_SAVE_AND_EXIT),
    9796      text   = STRING_TOKEN (STR_NO_SAVE_AND_EXIT),
    98         text   = STRING_TOKEN (STR_NO_SAVE_AND_EXIT),
    9997      flags  = INTERACTIVE,
    10098      key    = KEY_IGNORE_ORDER_CHANGES;
     
    110108      help   = STRING_TOKEN (STR_SAVE_AND_EXIT),
    111109      text   = STRING_TOKEN (STR_SAVE_AND_EXIT),
    112         text   = STRING_TOKEN (STR_SAVE_AND_EXIT),
    113110      flags  = INTERACTIVE,
    114111      key    = KEY_SAVE_DELETE_ATTEMPT;
     
    117114      help   = STRING_TOKEN (STR_NO_SAVE_AND_EXIT),
    118115      text   = STRING_TOKEN (STR_NO_SAVE_AND_EXIT),
    119         text   = STRING_TOKEN (STR_NO_SAVE_AND_EXIT),
    120116      flags  = INTERACTIVE,
    121117      key    = KEY_IGNORE_DELETE_ATTEMPT;
     
    354350      help   = STRING_TOKEN (STR_SAVE_CHANGES_HELP),
    355351      text   = STRING_TOKEN (STR_SAVE_CHANGES),
    356         text   = STRING_TOKEN (STR_SAVE_CHANGES),
    357352      flags  = INTERACTIVE,
    358353      key    = KEY_SAVE_ATTEMPT_CONFIG;
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/IScsiDxe/IScsiDhcp6.c

    r48674 r58459  
    22  iSCSI DHCP6 related configuration routines.
    33
    4 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    251251  EFI_DHCP6_PACKET_OPTION     **OptionList;
    252252  ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData;
     253  UINT16                      ParaLen;
    253254 
    254255  OptionCount = 0;
     
    283284
    284285      if (((OptionList[Index]->OpLen & 0xf) != 0) || (OptionList[Index]->OpLen == 0)) {
    285         Status = EFI_INVALID_PARAMETER;
     286        Status = EFI_UNSUPPORTED;
    286287        goto Exit;
    287288      }
     
    303304      //
    304305      BootFileOpt = OptionList[Index];
     306    } else if (OptionList[Index]->OpCode == DHCP6_OPT_BOOT_FILE_PARA) {
     307      //
     308      // The server sends this option to inform the client about DHCP6 server address.
     309      //
     310      if (OptionList[Index]->OpLen < 18) {
     311        Status = EFI_UNSUPPORTED;
     312        goto Exit;
     313      }
     314      //
     315      // Check param-len 1, should be 16 bytes.
     316      //
     317      CopyMem (&ParaLen, &OptionList[Index]->Data[0], sizeof (UINT16));
     318      if (NTOHS (ParaLen) != 16) {
     319        Status = EFI_UNSUPPORTED;
     320        goto Exit;
     321      }
     322
     323      CopyMem (&ConfigData->DhcpServer, &OptionList[Index]->Data[2], sizeof (EFI_IPv6_ADDRESS));
    305324    }
    306325  }
     
    406425  }
    407426
    408   Oro = AllocateZeroPool (sizeof (EFI_DHCP6_PACKET_OPTION) + 3);
     427  Oro = AllocateZeroPool (sizeof (EFI_DHCP6_PACKET_OPTION) + 5);
    409428  if (Oro == NULL) {
    410429    Status = EFI_OUT_OF_RESOURCES;
     
    417436  //
    418437  Oro->OpCode  = HTONS (DHCP6_OPT_REQUEST_OPTION);
    419   Oro->OpLen   = HTONS (2 * 2);
     438  Oro->OpLen   = HTONS (2 * 3);
    420439  Oro->Data[1] = DHCP6_OPT_DNS_SERVERS;
    421440  Oro->Data[3] = DHCP6_OPT_BOOT_FILE_URL;
     441  Oro->Data[5] = DHCP6_OPT_BOOT_FILE_PARA;
    422442
    423443  InfoReqReXmit.Irt = 4;
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/IScsiDxe/IScsiDhcp6.h

    r48674 r58459  
    22  The header file of iSCSI DHCP6 related configuration routines.
    33
    4 Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    2323///
    2424#define DHCP6_OPT_BOOT_FILE_URL  59
     25#define DHCP6_OPT_BOOT_FILE_PARA 60
    2526
    2627#define ISCSI_ROOT_PATH_ID                   "iscsi:"
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/IScsiDxe/IScsiDriver.c

    r48674 r58459  
    22  The entry point of IScsi driver.
    33
    4 Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    1515#include "IScsiImpl.h"
    1616
    17 EFI_DRIVER_BINDING_PROTOCOL gIScsiDriverBinding = {
    18   IScsiDriverBindingSupported,
    19   IScsiDriverBindingStart,
    20   IScsiDriverBindingStop,
     17EFI_DRIVER_BINDING_PROTOCOL gIScsiIp4DriverBinding = {
     18  IScsiIp4DriverBindingSupported,
     19  IScsiIp4DriverBindingStart,
     20  IScsiIp4DriverBindingStop,
    2121  0xa,
    2222  NULL,
     
    2424};
    2525
    26 EFI_GUID                    mIScsiV4PrivateGuid = ISCSI_V4_PRIVATE_GUID;
    27 EFI_GUID                    mIScsiV6PrivateGuid = ISCSI_V6_PRIVATE_GUID;
     26EFI_DRIVER_BINDING_PROTOCOL gIScsiIp6DriverBinding = {
     27  IScsiIp6DriverBindingSupported,
     28  IScsiIp6DriverBindingStart,
     29  IScsiIp6DriverBindingStop,
     30  0xa,
     31  NULL,
     32  NULL
     33};
     34
     35EFI_GUID                    gIScsiV4PrivateGuid = ISCSI_V4_PRIVATE_GUID;
     36EFI_GUID                    gIScsiV6PrivateGuid = ISCSI_V6_PRIVATE_GUID;
    2837ISCSI_PRIVATE_DATA          *mPrivate           = NULL;
    2938
    3039/**
    31   Tests to see if this driver supports the RemainingDevicePath.
     40  Tests to see if this driver supports the RemainingDevicePath. 
    3241
    3342  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This
     
    6877
    6978/**
    70   Tests to see if this driver supports a given controller. If a child device is provided,
    71   it further tests to see if this driver supports creating a handle for the specified child device.
    72 
    73   This function checks to see if the driver specified by This supports the device specified by
    74   ControllerHandle. Drivers typically use the device path attached to
    75   ControllerHandle and/or the services from the bus I/O abstraction attached to
    76   ControllerHandle to determine if the driver supports ControllerHandle. This function
    77   may be called many times during platform initialization. In order to reduce boot times, the tests
    78   performed by this function must be very small and take as little time as possible to execute. This
    79   function must not change the state of any hardware devices, and this function must be aware that the
    80   device specified by ControllerHandle may already be managed by the same driver or a
    81   different driver. This function must match its calls to AllocatePages() with FreePages(),
    82   AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol(). 
    83   Since ControllerHandle may have been previously started by the same driver, if a protocol is
    84   already in the opened state, then it must not be closed with CloseProtocol(). This is required
    85   to guarantee the state of ControllerHandle is not modified by this function.
     79  Tests to see if this driver supports a given controller. This is the worker function for
     80  IScsiIp4(6)DriverBindingSupported.
    8681
    8782  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
     
    9691                                   by RemainingDevicePath are both supported by this
    9792                                   bus driver.
     93  @param[in]  IpVersion            IP_VERSION_4 or IP_VERSION_6.
    9894
    9995  @retval EFI_SUCCESS              The device specified by ControllerHandle and
     
    10298                                   RemainingDevicePath is already being managed by the driver
    10399                                   specified by This.
    104   @retval EFI_ACCESS_DENIED        The device specified by ControllerHandle and
    105                                    RemainingDevicePath is already being managed by a different
    106                                    driver or an application that requires exclusive access.
    107                                    Currently not implemented.
    108100  @retval EFI_UNSUPPORTED          The device specified by ControllerHandle and
    109101                                   RemainingDevicePath is not supported by the driver specified by This.
     
    111103EFI_STATUS
    112104EFIAPI
    113 IScsiDriverBindingSupported (
     105IScsiSupported (
    114106  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
    115107  IN EFI_HANDLE                   ControllerHandle,
    116   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
     108  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL,
     109  IN UINT8                        IpVersion
    117110  )
    118111{
    119112  EFI_STATUS                Status;
    120   BOOLEAN                   IsIscsi4Started;
     113  EFI_GUID                  *IScsiServiceBindingGuid;
     114  EFI_GUID                  *TcpServiceBindingGuid;
     115  EFI_GUID                  *DhcpServiceBindingGuid;
     116
     117  if (IpVersion == IP_VERSION_4) {
     118    IScsiServiceBindingGuid  = &gIScsiV4PrivateGuid;
     119    TcpServiceBindingGuid    = &gEfiTcp4ServiceBindingProtocolGuid;
     120    DhcpServiceBindingGuid   = &gEfiDhcp4ServiceBindingProtocolGuid;
     121  } else {
     122    IScsiServiceBindingGuid  = &gIScsiV6PrivateGuid;
     123    TcpServiceBindingGuid    = &gEfiTcp6ServiceBindingProtocolGuid;
     124    DhcpServiceBindingGuid   = &gEfiDhcp6ServiceBindingProtocolGuid;
     125  }
    121126
    122127  Status = gBS->OpenProtocol (
    123128                  ControllerHandle,
    124                   &mIScsiV4PrivateGuid,
     129                  IScsiServiceBindingGuid,
    125130                  NULL,
    126131                  This->DriverBindingHandle,
     
    129134                  );
    130135  if (!EFI_ERROR (Status)) {
    131     IsIscsi4Started = TRUE;
    132   } else {
     136    return EFI_ALREADY_STARTED;
     137  }
     138
     139  Status = gBS->OpenProtocol (
     140                  ControllerHandle,
     141                  TcpServiceBindingGuid,
     142                  NULL,
     143                  This->DriverBindingHandle,
     144                  ControllerHandle,
     145                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
     146                  );
     147  if (EFI_ERROR (Status)) {
     148    return EFI_UNSUPPORTED;
     149  }
     150
     151  Status = IScsiIsDevicePathSupported (RemainingDevicePath);
     152  if (EFI_ERROR (Status)) {
     153    return EFI_UNSUPPORTED;
     154  }
     155
     156  if (IScsiDhcpIsConfigured (ControllerHandle, IpVersion)) {
    133157    Status = gBS->OpenProtocol (
    134158                    ControllerHandle,
    135                     &gEfiTcp4ServiceBindingProtocolGuid,
     159                    DhcpServiceBindingGuid,
    136160                    NULL,
    137161                    This->DriverBindingHandle,
     
    139163                    EFI_OPEN_PROTOCOL_TEST_PROTOCOL
    140164                    );
    141     if (!EFI_ERROR (Status)) {
    142       Status = IScsiIsDevicePathSupported (RemainingDevicePath);
    143       if (!EFI_ERROR (Status)) {
    144         return EFI_SUCCESS;
    145       }
    146     }
    147 
    148     IsIscsi4Started = FALSE;
    149   }
    150 
    151   Status = gBS->OpenProtocol (
    152                   ControllerHandle,
    153                   &mIScsiV6PrivateGuid,
    154                   NULL,
    155                   This->DriverBindingHandle,
    156                   ControllerHandle,
    157                   EFI_OPEN_PROTOCOL_TEST_PROTOCOL
    158                   );
    159   if (!EFI_ERROR (Status)) {
    160     if (IsIscsi4Started) {
    161       return EFI_ALREADY_STARTED;
    162     }
    163   } else {
    164     Status = gBS->OpenProtocol (
    165                     ControllerHandle,
    166                     &gEfiTcp6ServiceBindingProtocolGuid,
    167                     NULL,
    168                     This->DriverBindingHandle,
    169                     ControllerHandle,
    170                     EFI_OPEN_PROTOCOL_TEST_PROTOCOL
    171                     );
    172     if (!EFI_ERROR (Status)) {
    173       Status = IScsiIsDevicePathSupported (RemainingDevicePath);
    174       if (!EFI_ERROR (Status)) {
    175         return EFI_SUCCESS;
    176       }
    177     }
    178   }
    179 
    180   return EFI_UNSUPPORTED;
     165    if (EFI_ERROR (Status)) {
     166      return EFI_UNSUPPORTED;
     167    }
     168  }
     169 
     170  return EFI_SUCCESS;
    181171}
    182172
     
    184174/**
    185175  Start to manage the controller. This is the worker function for
    186   IScsiDriverBindingStart.
     176  IScsiIp4(6)DriverBindingStart.
    187177
    188178  @param[in]  Image                Handle of the image.
    189179  @param[in]  ControllerHandle     Handle of the controller.
    190   @param[in]  IpVersion            Ip4 or Ip6
    191 
    192   @retval EFI_SUCCES            This driver supports this device.
     180  @param[in]  IpVersion            IP_VERSION_4 or IP_VERSION_6.
     181
     182  @retval EFI_SUCCES            This driver was started.
    193183  @retval EFI_ALREADY_STARTED   This driver is already running on this device.
    194184  @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
     
    232222
    233223  if (IpVersion == IP_VERSION_4) {
    234     IScsiPrivateGuid      = &mIScsiV4PrivateGuid;
     224    IScsiPrivateGuid      = &gIScsiV4PrivateGuid;
    235225    TcpServiceBindingGuid = &gEfiTcp4ServiceBindingProtocolGuid;
    236226    ProtocolGuid          = &gEfiTcp4ProtocolGuid;
    237227  } else if (IpVersion == IP_VERSION_6) {
    238     IScsiPrivateGuid      = &mIScsiV6PrivateGuid;
     228    IScsiPrivateGuid      = &gIScsiV6PrivateGuid;
    239229    TcpServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid;
    240230    ProtocolGuid          = &gEfiTcp6ProtocolGuid;
     
    301291
    302292  Status = gBS->OpenProtocol (
    303                   Private->ChildHandle,
     293                  Private->ChildHandle, /// Default Tcp child
    304294                  ProtocolGuid,
    305295                  &Interface,
     
    662652                           &AttemptConfigOrderSize
    663653                           );
    664     ASSERT (AttemptConfigOrder != NULL);
     654    if (AttemptConfigOrder == NULL) {
     655      goto ON_ERROR;
     656    }
    665657    for (Index = 0; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) {
    666658      if (AttemptConfigOrder[Index] == mPrivate->BootSelectedIndex ||
     
    700692        goto ON_EXIT;
    701693      } else {
    702         ASSERT (AttemptConfigOrder[Index] == BootSelected);
     694        if (AttemptConfigOrder[Index] != BootSelected) {
     695          goto ON_ERROR;
     696        }
    703697        mPrivate->BootSelectedIndex = BootSelected;
    704698        //
     
    757751  }
    758752
     753  //
     754  // ISCSI children should share the default Tcp child, just open the default Tcp child via BY_CHILD_CONTROLLER.
     755  //
     756  Status = gBS->OpenProtocol (
     757                  Private->ChildHandle, /// Default Tcp child
     758                  ProtocolGuid,
     759                  &Interface,
     760                  Image,
     761                  Private->ExtScsiPassThruHandle,
     762                  EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
     763                  );             
     764  if (EFI_ERROR (Status)) {
     765    gBS->UninstallMultipleProtocolInterfaces (
     766           Private->ExtScsiPassThruHandle,
     767           &gEfiExtScsiPassThruProtocolGuid,
     768           &Private->IScsiExtScsiPassThru,
     769           &gEfiDevicePathProtocolGuid,
     770           Private->DevicePath,
     771           NULL
     772           );
     773   
     774    goto ON_ERROR;
     775  }
     776
    759777ON_EXIT:
    760778
     
    775793
    776794  return Status;
     795}
     796
     797/**
     798  Stops a device controller or a bus controller. This is the worker function for
     799  IScsiIp4(6)DriverBindingStop.
     800 
     801  @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
     802  @param[in]  ControllerHandle  A handle to the device being stopped. The handle must
     803                                support a bus specific I/O protocol for the driver
     804                                to use to stop the device.
     805  @param[in]  NumberOfChildren  The number of child device handles in ChildHandleBuffer.
     806  @param[in]  ChildHandleBuffer An array of child handles to be freed. May be NULL
     807                                if NumberOfChildren is 0.
     808  @param[in]  IpVersion         IP_VERSION_4 or IP_VERSION_6.
     809 
     810  @retval EFI_SUCCESS           The device was stopped.
     811  @retval EFI_DEVICE_ERROR      The device could not be stopped due to a device error.
     812
     813**/
     814EFI_STATUS
     815EFIAPI
     816IScsiStop (
     817  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     818  IN EFI_HANDLE                   ControllerHandle,
     819  IN UINTN                        NumberOfChildren,
     820  IN EFI_HANDLE                   *ChildHandleBuffer OPTIONAL,
     821  IN UINT8                        IpVersion
     822  )
     823{
     824  EFI_HANDLE                      IScsiController;
     825  EFI_STATUS                      Status;
     826  ISCSI_PRIVATE_PROTOCOL          *IScsiIdentifier;
     827  ISCSI_DRIVER_DATA               *Private;
     828  EFI_EXT_SCSI_PASS_THRU_PROTOCOL *PassThru;
     829  ISCSI_CONNECTION                *Conn;
     830  EFI_GUID                        *ProtocolGuid;
     831  EFI_GUID                        *TcpServiceBindingGuid;
     832  EFI_GUID                        *TcpProtocolGuid;
     833
     834
     835  if (NumberOfChildren != 0) {
     836    //
     837    // We should have only one child.
     838    //
     839    Status = gBS->OpenProtocol (
     840                    ChildHandleBuffer[0],
     841                    &gEfiExtScsiPassThruProtocolGuid,
     842                    (VOID **) &PassThru,
     843                    This->DriverBindingHandle,
     844                    ControllerHandle,
     845                    EFI_OPEN_PROTOCOL_GET_PROTOCOL
     846                    );
     847    if (EFI_ERROR (Status)) {
     848      return EFI_DEVICE_ERROR;
     849    }
     850
     851    Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (PassThru);
     852    Conn    = NET_LIST_HEAD (&Private->Session->Conns, ISCSI_CONNECTION, Link);
     853
     854    //
     855    // Previously the TCP protocol is opened BY_CHILD_CONTROLLER. Just close
     856    // the protocol here, but do not uninstall the device path protocol and
     857    // EXT SCSI PASS THRU protocol installed on ExtScsiPassThruHandle.
     858    //
     859    if (IpVersion == IP_VERSION_4) {
     860      ProtocolGuid = &gEfiTcp4ProtocolGuid;
     861    } else {
     862      ProtocolGuid = &gEfiTcp6ProtocolGuid;
     863    }
     864
     865    gBS->CloseProtocol (
     866           Private->ChildHandle,
     867           ProtocolGuid,
     868           Private->Image,
     869           Private->ExtScsiPassThruHandle
     870           );
     871   
     872    gBS->CloseProtocol (
     873           Conn->TcpIo.Handle,
     874           ProtocolGuid,
     875           Private->Image,
     876           Private->ExtScsiPassThruHandle
     877           );
     878
     879    return EFI_SUCCESS;
     880  }
     881 
     882  //
     883  // Get the handle of the controller we are controling.
     884  //
     885  if (IpVersion == IP_VERSION_4) {
     886    ProtocolGuid            = &gIScsiV4PrivateGuid;
     887    TcpProtocolGuid         = &gEfiTcp4ProtocolGuid;
     888    TcpServiceBindingGuid   = &gEfiTcp4ServiceBindingProtocolGuid;
     889  } else {
     890    ProtocolGuid            = &gIScsiV6PrivateGuid;
     891    TcpProtocolGuid         = &gEfiTcp6ProtocolGuid;
     892    TcpServiceBindingGuid   = &gEfiTcp6ServiceBindingProtocolGuid;
     893  }
     894  IScsiController = NetLibGetNicHandle (ControllerHandle, TcpProtocolGuid);
     895  if (IScsiController == NULL) {
     896    return EFI_SUCCESS;
     897  }
     898
     899  Status = gBS->OpenProtocol (
     900                  IScsiController,
     901                  ProtocolGuid,
     902                  (VOID **) &IScsiIdentifier,
     903                  This->DriverBindingHandle,
     904                  ControllerHandle,
     905                  EFI_OPEN_PROTOCOL_GET_PROTOCOL
     906                  );
     907  if (EFI_ERROR (Status)) {
     908    return EFI_DEVICE_ERROR;
     909  }
     910
     911  Private = ISCSI_DRIVER_DATA_FROM_IDENTIFIER (IScsiIdentifier);
     912  ASSERT (Private != NULL);
     913
     914  if (Private->ChildHandle != NULL) {
     915    Status = gBS->CloseProtocol (
     916                    Private->ChildHandle,
     917                    TcpProtocolGuid,
     918                    This->DriverBindingHandle,
     919                    IScsiController
     920                    );
     921                   
     922    ASSERT (!EFI_ERROR (Status));
     923
     924    Status = NetLibDestroyServiceChild (
     925               IScsiController,
     926               This->DriverBindingHandle,
     927               TcpServiceBindingGuid,
     928               Private->ChildHandle
     929               );
     930
     931    ASSERT (!EFI_ERROR (Status));
     932  }
     933
     934  gBS->UninstallProtocolInterface (
     935         IScsiController,
     936         ProtocolGuid,
     937         &Private->IScsiIdentifier
     938         );
     939
     940  //
     941  // Remove this NIC.
     942  //
     943  IScsiRemoveNic (IScsiController);
     944
     945  //
     946  // Update the iSCSI Boot Firware Table.
     947  //
     948  IScsiPublishIbft ();
     949
     950  if (Private->Session != NULL) {
     951    IScsiSessionAbort (Private->Session);
     952  }
     953
     954  IScsiCleanDriverData (Private);
     955
     956  return EFI_SUCCESS;
     957}
     958
     959/**
     960  Tests to see if this driver supports a given controller. If a child device is provided,
     961  it tests to see if this driver supports creating a handle for the specified child device.
     962
     963  This function checks to see if the driver specified by This supports the device specified by
     964  ControllerHandle. Drivers typically use the device path attached to
     965  ControllerHandle and/or the services from the bus I/O abstraction attached to
     966  ControllerHandle to determine if the driver supports ControllerHandle. This function
     967  may be called many times during platform initialization. In order to reduce boot times, the tests
     968  performed by this function must be very small and take as little time as possible to execute. This
     969  function must not change the state of any hardware devices, and this function must be aware that the
     970  device specified by ControllerHandle may already be managed by the same driver or a
     971  different driver. This function must match its calls to AllocatePages() with FreePages(),
     972  AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol(). 
     973  Since ControllerHandle may have been previously started by the same driver, if a protocol is
     974  already in the opened state, then it must not be closed with CloseProtocol(). This is required
     975  to guarantee the state of ControllerHandle is not modified by this function.
     976
     977  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
     978  @param[in]  ControllerHandle     The handle of the controller to test. This handle
     979                                   must support a protocol interface that supplies
     980                                   an I/O abstraction to the driver.
     981  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This
     982                                   parameter is ignored by device drivers, and is optional for bus
     983                                   drivers. For bus drivers, if this parameter is not NULL, then
     984                                   the bus driver must determine if the bus controller specified
     985                                   by ControllerHandle and the child controller specified
     986                                   by RemainingDevicePath are both supported by this
     987                                   bus driver.
     988
     989  @retval EFI_SUCCESS              The device specified by ControllerHandle and
     990                                   RemainingDevicePath is supported by the driver specified by This.
     991  @retval EFI_ALREADY_STARTED      The device specified by ControllerHandle and
     992                                   RemainingDevicePath is already managed by the driver
     993                                   specified by This.
     994  @retval EFI_ACCESS_DENIED        The device specified by ControllerHandle and
     995                                   RemainingDevicePath is already managed by a different
     996                                   driver or an application that requires exclusive access.
     997                                   Currently not implemented.
     998  @retval EFI_UNSUPPORTED          The device specified by ControllerHandle and
     999                                   RemainingDevicePath is not supported by the driver specified by This.
     1000**/
     1001EFI_STATUS
     1002EFIAPI
     1003IScsiIp4DriverBindingSupported (
     1004  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     1005  IN EFI_HANDLE                   ControllerHandle,
     1006  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
     1007  )
     1008{
     1009  return IScsiSupported (
     1010           This,
     1011           ControllerHandle,
     1012           RemainingDevicePath,
     1013           IP_VERSION_4
     1014           );
    7771015}
    7781016
     
    8071045
    8081046  @retval EFI_SUCCESS              The device was started.
    809   @retval EFI_DEVICE_ERROR         The device could not be started due to a device error.Currently not implemented.
     1047  @retval EFI_DEVICE_ERROR         The device could not be started due to a device error. Currently not implemented.
    8101048  @retval EFI_OUT_OF_RESOURCES     The request could not be completed due to a lack of resources.
    8111049  @retval Others                   The driver failed to start the device.
     
    8141052EFI_STATUS
    8151053EFIAPI
    816 IScsiDriverBindingStart (
     1054IScsiIp4DriverBindingStart (
    8171055  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
    8181056  IN EFI_HANDLE                   ControllerHandle,
     
    8201058  )
    8211059{
    822   EFI_STATUS        V4Status;
    823   EFI_STATUS        V6Status;
    824 
    825   V4Status = IScsiStart (This->DriverBindingHandle, ControllerHandle, IP_VERSION_4);
    826   if (V4Status == EFI_ALREADY_STARTED) {
    827     V4Status = EFI_SUCCESS;
    828   }
    829 
    830   V6Status = IScsiStart (This->DriverBindingHandle, ControllerHandle, IP_VERSION_6);
    831   if (V6Status == EFI_ALREADY_STARTED) {
    832     V6Status = EFI_SUCCESS;
    833   }
    834 
    835   if (!EFI_ERROR (V4Status) || !EFI_ERROR (V6Status)) {
    836     return EFI_SUCCESS;
    837   } else if (EFI_ERROR (V4Status)) {
    838     return V4Status;
    839   } else {
    840     return V6Status;
    841   }
     1060  EFI_STATUS        Status;
     1061
     1062  Status = IScsiStart (This->DriverBindingHandle, ControllerHandle, IP_VERSION_4);
     1063  if (Status == EFI_ALREADY_STARTED) {
     1064    Status = EFI_SUCCESS;
     1065  }
     1066
     1067  return Status;
    8421068}
    8431069
     
    8701096EFI_STATUS
    8711097EFIAPI
    872 IScsiDriverBindingStop (
     1098IScsiIp4DriverBindingStop (
    8731099  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
    8741100  IN EFI_HANDLE                   ControllerHandle,
     
    8771103  )
    8781104{
    879   EFI_HANDLE                      IScsiController;
    880   EFI_STATUS                      Status;
    881   ISCSI_PRIVATE_PROTOCOL          *IScsiIdentifier;
    882   ISCSI_DRIVER_DATA               *Private;
    883   EFI_EXT_SCSI_PASS_THRU_PROTOCOL *PassThru;
    884   ISCSI_CONNECTION                *Conn;
    885   EFI_GUID                        *ProtocolGuid;
    886   EFI_GUID                        *TcpServiceBindingGuid;
    887   EFI_GUID                        *TcpProtocolGuid;
    888 
    889 
    890   if (NumberOfChildren != 0) {
    891     //
    892     // We should have only one child.
    893     //
    894     Status = gBS->OpenProtocol (
    895                     ChildHandleBuffer[0],
    896                     &gEfiExtScsiPassThruProtocolGuid,
    897                     (VOID **) &PassThru,
    898                     This->DriverBindingHandle,
    899                     ControllerHandle,
    900                     EFI_OPEN_PROTOCOL_GET_PROTOCOL
    901                     );
    902     if (EFI_ERROR (Status)) {
    903       return EFI_DEVICE_ERROR;
    904     }
    905 
    906     Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (PassThru);
    907     Conn    = NET_LIST_HEAD (&Private->Session->Conns, ISCSI_CONNECTION, Link);
    908 
    909     //
    910     // Previously the TCP protocol is opened BY_CHILD_CONTROLLER. Just close
    911     // the protocol here, but do not uninstall the device path protocol and
    912     // EXT SCSI PASS THRU protocol installed on ExtScsiPassThruHandle.
    913     //
    914     if (!Conn->Ipv6Flag) {
    915       ProtocolGuid = &gEfiTcp4ProtocolGuid;
    916     } else {
    917       ProtocolGuid = &gEfiTcp6ProtocolGuid;
    918     }
    919 
    920     gBS->CloseProtocol (
    921            Conn->TcpIo.Handle,
    922            ProtocolGuid,
    923            Private->Image,
    924            Private->ExtScsiPassThruHandle
     1105  return IScsiStop (
     1106           This,
     1107           ControllerHandle,
     1108           NumberOfChildren,
     1109           ChildHandleBuffer,
     1110           IP_VERSION_4
    9251111           );
    926 
    927     return EFI_SUCCESS;
    928   }
    929   //
    930   // Get the handle of the controller we are controling.
    931   //
    932   IScsiController = NetLibGetNicHandle (ControllerHandle, &gEfiTcp4ProtocolGuid);
    933   if (IScsiController != NULL) {
    934     ProtocolGuid            = &mIScsiV4PrivateGuid;
    935     TcpProtocolGuid         = &gEfiTcp4ProtocolGuid;
    936     TcpServiceBindingGuid   = &gEfiTcp4ServiceBindingProtocolGuid;
    937   } else {
    938     IScsiController = NetLibGetNicHandle (ControllerHandle, &gEfiTcp6ProtocolGuid);
    939     ASSERT (IScsiController != NULL);
    940     ProtocolGuid            = &mIScsiV6PrivateGuid;
    941     TcpProtocolGuid         = &gEfiTcp6ProtocolGuid;
    942     TcpServiceBindingGuid   = &gEfiTcp6ServiceBindingProtocolGuid;
    943   }
    944 
    945   Status = gBS->OpenProtocol (
    946                   IScsiController,
    947                   ProtocolGuid,
    948                   (VOID **) &IScsiIdentifier,
    949                   This->DriverBindingHandle,
    950                   ControllerHandle,
    951                   EFI_OPEN_PROTOCOL_GET_PROTOCOL
    952                   );
    953   if (EFI_ERROR (Status)) {
    954     return EFI_DEVICE_ERROR;
    955   }
    956 
    957   Private = ISCSI_DRIVER_DATA_FROM_IDENTIFIER (IScsiIdentifier);
    958   ASSERT (Private != NULL);
    959 
    960   if (Private->ChildHandle != NULL) {
    961     Status = gBS->CloseProtocol (
    962                     Private->ChildHandle,
    963                     TcpProtocolGuid,
    964                     This->DriverBindingHandle,
    965                     IScsiController
    966                     );
    967                    
    968     ASSERT (!EFI_ERROR (Status));
    969 
    970     Status = NetLibDestroyServiceChild (
    971                IScsiController,
    972                This->DriverBindingHandle,
    973                TcpServiceBindingGuid,
    974                Private->ChildHandle
    975                );
    976 
    977     ASSERT (!EFI_ERROR (Status));
    978   }
    979 
    980   gBS->UninstallProtocolInterface (
    981          IScsiController,
    982          ProtocolGuid,
    983          &Private->IScsiIdentifier
    984          );
    985 
    986   //
    987   // Remove this NIC.
    988   //
    989   IScsiRemoveNic (IScsiController);
    990 
    991   //
    992   // Update the iSCSI Boot Firware Table.
    993   //
    994   IScsiPublishIbft ();
    995 
    996   if (Private->Session != NULL) {
    997     IScsiSessionAbort (Private->Session);
    998   }
    999 
    1000   IScsiCleanDriverData (Private);
    1001 
    1002   return EFI_SUCCESS;
    10031112}
    10041113
     1114/**
     1115  Tests to see if this driver supports a given controller. If a child device is provided,
     1116  it tests to see if this driver supports creating a handle for the specified child device.
     1117
     1118  This function checks to see if the driver specified by This supports the device specified by
     1119  ControllerHandle. Drivers typically use the device path attached to
     1120  ControllerHandle and/or the services from the bus I/O abstraction attached to
     1121  ControllerHandle to determine if the driver supports ControllerHandle. This function
     1122  may be called many times during platform initialization. In order to reduce boot times, the tests
     1123  performed by this function must be very small and take as little time as possible to execute. This
     1124  function must not change the state of any hardware devices, and this function must be aware that the
     1125  device specified by ControllerHandle may already be managed by the same driver or a
     1126  different driver. This function must match its calls to AllocatePages() with FreePages(),
     1127  AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol(). 
     1128  Since ControllerHandle may have been previously started by the same driver, if a protocol is
     1129  already in the opened state, then it must not be closed with CloseProtocol(). This is required
     1130  to guarantee the state of ControllerHandle is not modified by this function.
     1131
     1132  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
     1133  @param[in]  ControllerHandle     The handle of the controller to test. This handle
     1134                                   must support a protocol interface that supplies
     1135                                   an I/O abstraction to the driver.
     1136  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This
     1137                                   parameter is ignored by device drivers, and is optional for bus
     1138                                   drivers. For bus drivers, if this parameter is not NULL, then
     1139                                   the bus driver must determine if the bus controller specified
     1140                                   by ControllerHandle and the child controller specified
     1141                                   by RemainingDevicePath are both supported by this
     1142                                   bus driver.
     1143
     1144  @retval EFI_SUCCESS              The device specified by ControllerHandle and
     1145                                   RemainingDevicePath is supported by the driver specified by This.
     1146  @retval EFI_ALREADY_STARTED      The device specified by ControllerHandle and
     1147                                   RemainingDevicePath is already managed by the driver
     1148                                   specified by This.
     1149  @retval EFI_ACCESS_DENIED        The device specified by ControllerHandle and
     1150                                   RemainingDevicePath is already managed by a different
     1151                                   driver or an application that requires exclusive access.
     1152                                   Currently not implemented.
     1153  @retval EFI_UNSUPPORTED          The device specified by ControllerHandle and
     1154                                   RemainingDevicePath is not supported by the driver specified by This.
     1155**/
     1156EFI_STATUS
     1157EFIAPI
     1158IScsiIp6DriverBindingSupported (
     1159  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     1160  IN EFI_HANDLE                   ControllerHandle,
     1161  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
     1162  )
     1163{
     1164  return IScsiSupported (
     1165           This,
     1166           ControllerHandle,
     1167           RemainingDevicePath,
     1168           IP_VERSION_6
     1169           );
     1170}
     1171
     1172/**
     1173  Starts a device controller or a bus controller.
     1174
     1175  The Start() function is designed to be invoked from the EFI boot service ConnectController().
     1176  As a result, much of the error checking on the parameters to Start() has been moved into this
     1177  common boot service. It is legal to call Start() from other locations,
     1178  but the following calling restrictions must be followed or the system behavior will not be deterministic.
     1179  1. ControllerHandle must be a valid EFI_HANDLE.
     1180  2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
     1181     EFI_DEVICE_PATH_PROTOCOL.
     1182  3. Prior to calling Start(), the Supported() function for the driver specified by This must
     1183     have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS. 
     1184
     1185  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
     1186  @param[in]  ControllerHandle     The handle of the controller to start. This handle
     1187                                   must support a protocol interface that supplies
     1188                                   an I/O abstraction to the driver.
     1189  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This
     1190                                   parameter is ignored by device drivers, and is optional for bus
     1191                                   drivers. For a bus driver, if this parameter is NULL, then handles
     1192                                   for all the children of Controller are created by this driver. 
     1193                                   If this parameter is not NULL and the first Device Path Node is
     1194                                   not the End of Device Path Node, then only the handle for the
     1195                                   child device specified by the first Device Path Node of
     1196                                   RemainingDevicePath is created by this driver.
     1197                                   If the first Device Path Node of RemainingDevicePath is
     1198                                   the End of Device Path Node, no child handle is created by this
     1199                                   driver.
     1200
     1201  @retval EFI_SUCCESS              The device was started.
     1202  @retval EFI_DEVICE_ERROR         The device could not be started due to a device error. Currently not implemented.
     1203  @retval EFI_OUT_OF_RESOURCES     The request could not be completed due to a lack of resources.
     1204  @retval Others                   The driver failed to start the device.
     1205
     1206**/
     1207EFI_STATUS
     1208EFIAPI
     1209IScsiIp6DriverBindingStart (
     1210  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     1211  IN EFI_HANDLE                   ControllerHandle,
     1212  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
     1213  )
     1214{
     1215  EFI_STATUS        Status;
     1216
     1217  Status = IScsiStart (This->DriverBindingHandle, ControllerHandle, IP_VERSION_6);
     1218  if (Status == EFI_ALREADY_STARTED) {
     1219    Status = EFI_SUCCESS;
     1220  }
     1221
     1222  return Status;
     1223}
     1224
     1225/**
     1226  Stops a device controller or a bus controller.
     1227 
     1228  The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
     1229  As a result, much of the error checking on the parameters to Stop() has been moved
     1230  into this common boot service. It is legal to call Stop() from other locations,
     1231  but the following calling restrictions must be followed or the system behavior will not be deterministic.
     1232  1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
     1233     same driver's Start() function.
     1234  2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
     1235     EFI_HANDLE. In addition, all of these handles must have been created in this driver's
     1236     Start() function, and the Start() function must have called OpenProtocol() on
     1237     ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
     1238 
     1239  @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
     1240  @param[in]  ControllerHandle  A handle to the device being stopped. The handle must
     1241                                support a bus specific I/O protocol for the driver
     1242                                to use to stop the device.
     1243  @param[in]  NumberOfChildren  The number of child device handles in ChildHandleBuffer.
     1244  @param[in]  ChildHandleBuffer An array of child handles to be freed. May be NULL
     1245                                if NumberOfChildren is 0.
     1246
     1247  @retval EFI_SUCCESS           The device was stopped.
     1248  @retval EFI_DEVICE_ERROR      The device could not be stopped due to a device error.
     1249
     1250**/
     1251EFI_STATUS
     1252EFIAPI
     1253IScsiIp6DriverBindingStop (
     1254  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     1255  IN EFI_HANDLE                   ControllerHandle,
     1256  IN UINTN                        NumberOfChildren,
     1257  IN EFI_HANDLE                   *ChildHandleBuffer OPTIONAL
     1258  )
     1259{
     1260  return IScsiStop (
     1261           This,
     1262           ControllerHandle,
     1263           NumberOfChildren,
     1264           ChildHandleBuffer,
     1265           IP_VERSION_6
     1266           );
     1267}
    10051268
    10061269/**
     
    10191282  )
    10201283{
    1021   EFI_STATUS  Status;
    1022   UINTN       DeviceHandleCount;
    1023   EFI_HANDLE  *DeviceHandleBuffer;
    1024   UINTN       Index;
     1284  EFI_STATUS                        Status;
     1285  UINTN                             DeviceHandleCount;
     1286  EFI_HANDLE                        *DeviceHandleBuffer;
     1287  UINTN                             Index;
     1288  EFI_COMPONENT_NAME_PROTOCOL       *ComponentName;
     1289  EFI_COMPONENT_NAME2_PROTOCOL      *ComponentName2;
    10251290
    10261291  //
     
    10341299                  &DeviceHandleBuffer
    10351300                  );
     1301  if (EFI_ERROR (Status)) {
     1302    return Status;
     1303  }
     1304
     1305  //
     1306  // Disconnect the iSCSI4 driver from the controlled device.
     1307  //
     1308  for (Index = 0; Index < DeviceHandleCount; Index++) {
     1309    Status = IScsiTestManagedDevice (
     1310               DeviceHandleBuffer[Index],
     1311               gIScsiIp4DriverBinding.DriverBindingHandle,
     1312               &gEfiTcp4ProtocolGuid)
     1313               ;
     1314    if (EFI_ERROR (Status)) {
     1315      continue;
     1316    }
     1317    Status = gBS->DisconnectController (
     1318                    DeviceHandleBuffer[Index],
     1319                    gIScsiIp4DriverBinding.DriverBindingHandle,
     1320                    NULL
     1321                    );
     1322    if (EFI_ERROR (Status)) {
     1323      goto ON_EXIT;
     1324    }
     1325  }
     1326
     1327  //
     1328  // Disconnect the iSCSI6 driver from the controlled device.
     1329  //
     1330  for (Index = 0; Index < DeviceHandleCount; Index++) {
     1331    Status = IScsiTestManagedDevice (
     1332               DeviceHandleBuffer[Index],
     1333               gIScsiIp6DriverBinding.DriverBindingHandle,
     1334               &gEfiTcp6ProtocolGuid
     1335               );
     1336    if (EFI_ERROR (Status)) {
     1337      continue;
     1338    }
     1339    Status = gBS->DisconnectController (
     1340                    DeviceHandleBuffer[Index],
     1341                    gIScsiIp6DriverBinding.DriverBindingHandle,
     1342                    NULL
     1343                    );
     1344    if (EFI_ERROR (Status)) {
     1345      goto ON_EXIT;
     1346    }
     1347  }
     1348
     1349  //
     1350  // Unload the iSCSI configuration form.
     1351  //
     1352  Status = IScsiConfigFormUnload (gIScsiIp4DriverBinding.DriverBindingHandle);
     1353  if (EFI_ERROR (Status)) {
     1354    goto ON_EXIT;
     1355  }
     1356 
     1357  //
     1358  // Uninstall the protocols installed by iSCSI driver.
     1359  //
     1360  Status = gBS->UninstallMultipleProtocolInterfaces (
     1361                  ImageHandle,
     1362                  &gEfiAuthenticationInfoProtocolGuid,
     1363                  &gIScsiAuthenticationInfo,
     1364                  NULL
     1365                  );
     1366  if (EFI_ERROR (Status)) {
     1367    goto ON_EXIT;
     1368  }
     1369 
     1370  if (gIScsiControllerNameTable!= NULL) {
     1371    Status = FreeUnicodeStringTable (gIScsiControllerNameTable);
     1372    if (EFI_ERROR (Status)) {
     1373      goto ON_EXIT;
     1374    }
     1375    gIScsiControllerNameTable = NULL;
     1376  }
     1377
     1378  //
     1379  // Uninstall the ComponentName and ComponentName2 protocol from iSCSI4 driver binding handle
     1380  // if it has been installed.
     1381  //
     1382  Status = gBS->HandleProtocol (
     1383                  gIScsiIp4DriverBinding.DriverBindingHandle,
     1384                  &gEfiComponentNameProtocolGuid,
     1385                  (VOID **) &ComponentName
     1386                  );
    10361387  if (!EFI_ERROR (Status)) {
    1037     for (Index = 0; Index < DeviceHandleCount; Index++) {
    1038       Status = gBS->DisconnectController (
    1039                       DeviceHandleBuffer[Index],
    1040                       ImageHandle,
    1041                       NULL
    1042                       );
    1043     }
    1044 
    1045     if (DeviceHandleBuffer != NULL) {
    1046       FreePool (DeviceHandleBuffer);
    1047     }
    1048   }
    1049   //
    1050   // Unload the iSCSI configuration form.
    1051   //
    1052   IScsiConfigFormUnload (gIScsiDriverBinding.DriverBindingHandle);
    1053 
    1054   //
    1055   // Uninstall the protocols installed by iSCSI driver.
    1056   //
    1057   gBS->UninstallMultipleProtocolInterfaces (
    1058          ImageHandle,
    1059          &gEfiAuthenticationInfoProtocolGuid,
    1060          &gIScsiAuthenticationInfo,
    1061          NULL
    1062          );
     1388    Status = gBS->UninstallMultipleProtocolInterfaces (
     1389           gIScsiIp4DriverBinding.DriverBindingHandle,
     1390           &gEfiComponentNameProtocolGuid,
     1391           ComponentName,
     1392           NULL
     1393           );
     1394    if (EFI_ERROR (Status)) {
     1395      goto ON_EXIT;
     1396    }
     1397  }
    10631398 
    1064   return gBS->UninstallMultipleProtocolInterfaces (
    1065                 ImageHandle,
    1066                 &gEfiDriverBindingProtocolGuid,
    1067                 &gIScsiDriverBinding,
    1068                 &gEfiComponentName2ProtocolGuid,
    1069                 &gIScsiComponentName2,
    1070                 &gEfiComponentNameProtocolGuid,
    1071                 &gIScsiComponentName,
    1072                 &gEfiIScsiInitiatorNameProtocolGuid,
    1073                 &gIScsiInitiatorName,
    1074                 NULL
    1075                 );
     1399  Status = gBS->HandleProtocol (
     1400                  gIScsiIp4DriverBinding.DriverBindingHandle,
     1401                  &gEfiComponentName2ProtocolGuid,
     1402                  (VOID **) &ComponentName2
     1403                  );
     1404  if (!EFI_ERROR (Status)) {
     1405    gBS->UninstallMultipleProtocolInterfaces (
     1406           gIScsiIp4DriverBinding.DriverBindingHandle,
     1407           &gEfiComponentName2ProtocolGuid,
     1408           ComponentName2,
     1409           NULL
     1410           );
     1411    if (EFI_ERROR (Status)) {
     1412      goto ON_EXIT;
     1413    }
     1414  }
     1415
     1416  //
     1417  // Uninstall the ComponentName and ComponentName2 protocol from iSCSI6 driver binding handle
     1418  // if it has been installed.
     1419  //
     1420  Status = gBS->HandleProtocol (
     1421                  gIScsiIp6DriverBinding.DriverBindingHandle,
     1422                  &gEfiComponentNameProtocolGuid,
     1423                  (VOID **) &ComponentName
     1424                  );
     1425  if (!EFI_ERROR (Status)) {
     1426    Status = gBS->UninstallMultipleProtocolInterfaces (
     1427           gIScsiIp6DriverBinding.DriverBindingHandle,
     1428           &gEfiComponentNameProtocolGuid,
     1429           ComponentName,
     1430           NULL
     1431           );
     1432    if (EFI_ERROR (Status)) {
     1433      goto ON_EXIT;
     1434    }
     1435  }
     1436 
     1437  Status = gBS->HandleProtocol (
     1438                  gIScsiIp6DriverBinding.DriverBindingHandle,
     1439                  &gEfiComponentName2ProtocolGuid,
     1440                  (VOID **) &ComponentName2
     1441                  );
     1442  if (!EFI_ERROR (Status)) {
     1443    gBS->UninstallMultipleProtocolInterfaces (
     1444           gIScsiIp6DriverBinding.DriverBindingHandle,
     1445           &gEfiComponentName2ProtocolGuid,
     1446           ComponentName2,
     1447           NULL
     1448           );
     1449    if (EFI_ERROR (Status)) {
     1450      goto ON_EXIT;
     1451    }
     1452  }
     1453
     1454  //
     1455  // Uninstall the IScsiInitiatorNameProtocol and all the driver binding protocols.
     1456  //
     1457  Status = gBS->UninstallMultipleProtocolInterfaces (
     1458                  gIScsiIp4DriverBinding.DriverBindingHandle,
     1459                  &gEfiDriverBindingProtocolGuid,
     1460                  &gIScsiIp4DriverBinding,
     1461                  &gEfiIScsiInitiatorNameProtocolGuid,
     1462                  &gIScsiInitiatorName,
     1463                  NULL
     1464                  );
     1465  if (EFI_ERROR (Status)) {
     1466    goto ON_EXIT;
     1467  }
     1468
     1469  Status = gBS->UninstallMultipleProtocolInterfaces (
     1470                  gIScsiIp6DriverBinding.DriverBindingHandle,
     1471                  &gEfiDriverBindingProtocolGuid,
     1472                  &gIScsiIp6DriverBinding,
     1473                  NULL
     1474                  );
     1475
     1476ON_EXIT:
     1477
     1478  if (DeviceHandleBuffer != NULL) {
     1479    FreePool (DeviceHandleBuffer);
     1480  }
     1481 
     1482  return Status;
    10761483}
    10771484
     
    11211528             ImageHandle,
    11221529             SystemTable,
    1123              &gIScsiDriverBinding,
     1530             &gIScsiIp4DriverBinding,
    11241531             ImageHandle,
    11251532             &gIScsiComponentName,
     
    11301537  }
    11311538
     1539  Status = EfiLibInstallDriverBindingComponentName2 (
     1540             ImageHandle,
     1541             SystemTable,
     1542             &gIScsiIp6DriverBinding,
     1543             NULL,
     1544             &gIScsiComponentName,
     1545             &gIScsiComponentName2
     1546             );
     1547  if (EFI_ERROR (Status)) {
     1548    goto Error1;
     1549  }
     1550 
    11321551  //
    11331552  // Install the iSCSI Initiator Name Protocol.
     
    11401559                  );
    11411560  if (EFI_ERROR (Status)) {
    1142     goto Error1;
     1561    goto Error2;
    11431562  }
    11441563
     
    11491568  if (mPrivate == NULL) {
    11501569    Status = EFI_OUT_OF_RESOURCES;
    1151     goto Error2;
     1570    goto Error3;
    11521571  }
    11531572
     
    11581577  // Initialize the configuration form of iSCSI.
    11591578  //
    1160   Status = IScsiConfigFormInit (gIScsiDriverBinding.DriverBindingHandle);
    1161   if (EFI_ERROR (Status)) {
    1162     goto Error3;
     1579  Status = IScsiConfigFormInit (gIScsiIp4DriverBinding.DriverBindingHandle);
     1580  if (EFI_ERROR (Status)) {
     1581    goto Error4;
    11631582  }
    11641583
     
    11801599                    );
    11811600    if (EFI_ERROR (Status)) {
    1182       goto Error4;
     1601      goto Error5;
    11831602    }   
    11841603  }
     
    11861605  return EFI_SUCCESS;
    11871606
     1607Error5:
     1608  IScsiConfigFormUnload (gIScsiIp4DriverBinding.DriverBindingHandle);
     1609
    11881610Error4:
    1189   IScsiConfigFormUnload (gIScsiDriverBinding.DriverBindingHandle);
     1611  FreePool (mPrivate);
    11901612
    11911613Error3:
    1192   FreePool (mPrivate);
    1193 
    1194 Error2:
    11951614  gBS->UninstallMultipleProtocolInterfaces (
    11961615         ImageHandle,
     
    12001619         );
    12011620
    1202 Error1:
     1621Error2:
    12031622  gBS->UninstallMultipleProtocolInterfaces (
    1204          ImageHandle,
     1623         gIScsiIp6DriverBinding.DriverBindingHandle,
    12051624         &gEfiDriverBindingProtocolGuid,
    1206          &gIScsiDriverBinding,
     1625         &gIScsiIp6DriverBinding,
    12071626         &gEfiComponentName2ProtocolGuid,
    12081627         &gIScsiComponentName2,
     
    12121631         );
    12131632
     1633Error1:
     1634  gBS->UninstallMultipleProtocolInterfaces (
     1635         ImageHandle,
     1636         &gEfiDriverBindingProtocolGuid,
     1637         &gIScsiIp4DriverBinding,
     1638         &gEfiComponentName2ProtocolGuid,
     1639         &gIScsiComponentName2,
     1640         &gEfiComponentNameProtocolGuid,
     1641         &gIScsiComponentName,
     1642         NULL
     1643         );
     1644
    12141645  return Status;
    12151646}
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/IScsiDxe/IScsiDriver.h

    r48674 r58459  
    22  The header file of IScsiDriver.c.
    33
    4 Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    3434extern EFI_COMPONENT_NAME2_PROTOCOL       gIScsiComponentName2;
    3535extern EFI_COMPONENT_NAME_PROTOCOL        gIScsiComponentName;
     36extern EFI_UNICODE_STRING_TABLE           *gIScsiControllerNameTable;
    3637extern EFI_ISCSI_INITIATOR_NAME_PROTOCOL  gIScsiInitiatorName;
    3738extern EFI_AUTHENTICATION_INFO_PROTOCOL   gIScsiAuthenticationInfo;
    3839extern EFI_EXT_SCSI_PASS_THRU_PROTOCOL    gIScsiExtScsiPassThruProtocolTemplate;
     40extern EFI_GUID                           gIScsiV4PrivateGuid;
     41extern EFI_GUID                           gIScsiV6PrivateGuid;
    3942
    4043typedef struct {
     
    124127EFI_STATUS
    125128EFIAPI
    126 IScsiDriverBindingSupported (
     129IScsiIp4DriverBindingSupported (
    127130  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
    128131  IN EFI_HANDLE                   ControllerHandle,
     
    167170EFI_STATUS
    168171EFIAPI
    169 IScsiDriverBindingStart (
     172IScsiIp4DriverBindingStart (
    170173  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
    171174  IN EFI_HANDLE                   ControllerHandle,
     
    201204EFI_STATUS
    202205EFIAPI
    203 IScsiDriverBindingStop (
     206IScsiIp4DriverBindingStop (
     207  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     208  IN EFI_HANDLE                   ControllerHandle,
     209  IN UINTN                        NumberOfChildren,
     210  IN EFI_HANDLE                   *ChildHandleBuffer OPTIONAL
     211  );
     212
     213/**
     214  Tests to see if this driver supports a given controller. If a child device is provided,
     215  it tests to see if this driver supports creating a handle for the specified child device.
     216
     217  This function checks to see if the driver specified by This supports the device specified by
     218  ControllerHandle. Drivers typically use the device path attached to
     219  ControllerHandle and/or the services from the bus I/O abstraction attached to
     220  ControllerHandle to determine if the driver supports ControllerHandle. This function
     221  may be called many times during platform initialization. In order to reduce boot times, the tests
     222  performed by this function must be very small and take as little time as possible to execute. This
     223  function must not change the state of any hardware devices, and this function must be aware that the
     224  device specified by ControllerHandle may already be managed by the same driver or a
     225  different driver. This function must match its calls to AllocatePages() with FreePages(),
     226  AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol(). 
     227  Since ControllerHandle may have been previously started by the same driver, if a protocol is
     228  already in the opened state, then it must not be closed with CloseProtocol(). This is required
     229  to guarantee the state of ControllerHandle is not modified by this function.
     230
     231  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
     232  @param[in]  ControllerHandle     The handle of the controller to test. This handle
     233                                   must support a protocol interface that supplies
     234                                   an I/O abstraction to the driver.
     235  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This
     236                                   parameter is ignored by device drivers, and is optional for bus
     237                                   drivers. For bus drivers, if this parameter is not NULL, then
     238                                   the bus driver must determine if the bus controller specified
     239                                   by ControllerHandle and the child controller specified
     240                                   by RemainingDevicePath are both supported by this
     241                                   bus driver.
     242
     243  @retval EFI_SUCCESS              The device specified by ControllerHandle and
     244                                   RemainingDevicePath is supported by the driver specified by This.
     245  @retval EFI_ALREADY_STARTED      The device specified by ControllerHandle and
     246                                   RemainingDevicePath is already managed by the driver
     247                                   specified by This.
     248  @retval EFI_ACCESS_DENIED        The device specified by ControllerHandle and
     249                                   RemainingDevicePath is already managed by a different
     250                                   driver or an application that requires exclusive access.
     251                                   Currently not implemented.
     252  @retval EFI_UNSUPPORTED          The device specified by ControllerHandle and
     253                                   RemainingDevicePath is not supported by the driver specified by This.
     254**/
     255EFI_STATUS
     256EFIAPI
     257IScsiIp6DriverBindingSupported (
     258  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     259  IN EFI_HANDLE                   ControllerHandle,
     260  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
     261  );
     262
     263/**
     264  Starts a device controller or a bus controller.
     265
     266  The Start() function is designed to be invoked from the EFI boot service ConnectController().
     267  As a result, much of the error checking on the parameters to Start() has been moved into this
     268  common boot service. It is legal to call Start() from other locations,
     269  but the following calling restrictions must be followed or the system behavior will not be deterministic.
     270  1. ControllerHandle must be a valid EFI_HANDLE.
     271  2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
     272     EFI_DEVICE_PATH_PROTOCOL.
     273  3. Prior to calling Start(), the Supported() function for the driver specified by This must
     274     have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS. 
     275
     276  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
     277  @param[in]  ControllerHandle     The handle of the controller to start. This handle
     278                                   must support a protocol interface that supplies
     279                                   an I/O abstraction to the driver.
     280  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This
     281                                   parameter is ignored by device drivers, and is optional for bus
     282                                   drivers. For a bus driver, if this parameter is NULL, then handles
     283                                   for all the children of Controller are created by this driver. 
     284                                   If this parameter is not NULL and the first Device Path Node is
     285                                   not the End of Device Path Node, then only the handle for the
     286                                   child device specified by the first Device Path Node of
     287                                   RemainingDevicePath is created by this driver.
     288                                   If the first Device Path Node of RemainingDevicePath is
     289                                   the End of Device Path Node, no child handle is created by this
     290                                   driver.
     291
     292  @retval EFI_SUCCESS              The device was started.
     293  @retval EFI_DEVICE_ERROR         The device could not be started due to a device error. Currently not implemented.
     294  @retval EFI_OUT_OF_RESOURCES     The request could not be completed due to a lack of resources.
     295  @retval Others                   The driver failed to start the device.
     296
     297**/
     298EFI_STATUS
     299EFIAPI
     300IScsiIp6DriverBindingStart (
     301  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     302  IN EFI_HANDLE                   ControllerHandle,
     303  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
     304  );
     305
     306/**
     307  Stops a device controller or a bus controller.
     308 
     309  The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
     310  As a result, much of the error checking on the parameters to Stop() has been moved
     311  into this common boot service. It is legal to call Stop() from other locations,
     312  but the following calling restrictions must be followed or the system behavior will not be deterministic.
     313  1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
     314     same driver's Start() function.
     315  2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
     316     EFI_HANDLE. In addition, all of these handles must have been created in this driver's
     317     Start() function, and the Start() function must have called OpenProtocol() on
     318     ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
     319 
     320  @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
     321  @param[in]  ControllerHandle  A handle to the device being stopped. The handle must
     322                                support a bus specific I/O protocol for the driver
     323                                to use to stop the device.
     324  @param[in]  NumberOfChildren  The number of child device handles in ChildHandleBuffer.
     325  @param[in]  ChildHandleBuffer An array of child handles to be freed. May be NULL
     326                                if NumberOfChildren is 0.
     327
     328  @retval EFI_SUCCESS           The device was stopped.
     329  @retval EFI_DEVICE_ERROR      The device could not be stopped due to a device error.
     330
     331**/
     332EFI_STATUS
     333EFIAPI
     334IScsiIp6DriverBindingStop (
    204335  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
    205336  IN EFI_HANDLE                   ControllerHandle,
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/IScsiDxe/IScsiDxe.inf

    r48674 r58459  
    11## @file
    2 #  Component description file for IScsi module.
     2#  Client-side iSCSI service.
    33#
    4 # Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
     4#  The iSCSI driver provides iSCSI service in the preboot environment and supports
     5#  booting over iSCSI.
     6#                                                   
     7# Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
    58# This program and the accompanying materials
    69# are licensed and made available under the terms and conditions of the BSD License
     
    2124  ENTRY_POINT                    = IScsiDriverEntryPoint
    2225  UNLOAD_IMAGE                   = IScsiUnload
     26  MODULE_UNI_FILE                = IScsiDxe.uni
    2327
    2428#
     
    8387
    8488[Protocols]
    85   gEfiAcpiTableProtocolGuid                     # PROTOCOL ALWAYS_CONSUMED
    86   gEfiDriverBindingProtocolGuid                 # PROTOCOL ALWAYS_CONSUMED
    87   gEfiPciIoProtocolGuid                         # PROTOCOL ALWAYS_CONSUMED
    88   gEfiDhcp4ProtocolGuid                         # PROTOCOL ALWAYS_CONSUMED
    89   gEfiDhcp6ProtocolGuid                         # PROTOCOL ALWAYS_CONSUMED 
    90   gEfiDhcp4ServiceBindingProtocolGuid           # PROTOCOL ALWAYS_CONSUMED
    91   gEfiDhcp6ServiceBindingProtocolGuid           # PROTOCOL ALWAYS_CONSUMED 
    92   gEfiTcp4ProtocolGuid                          # PROTOCOL ALWAYS_CONSUMED
    93   gEfiTcp6ProtocolGuid                          # PROTOCOL ALWAYS_CONSUMED 
    94   gEfiTcp4ServiceBindingProtocolGuid            # PROTOCOL ALWAYS_CONSUMED
    95   gEfiTcp6ServiceBindingProtocolGuid            # PROTOCOL ALWAYS_CONSUMED 
    96   gEfiExtScsiPassThruProtocolGuid               # PROTOCOL ALWAYS_CONSUMED
    97   gEfiHiiConfigAccessProtocolGuid               # PROTOCOL ALWAYS_CONSUMED
    98   gEfiDevicePathProtocolGuid                    # PROTOCOL ALWAYS_CONSUMED
    99   gEfiIScsiInitiatorNameProtocolGuid            # PROTOCOL ALWAYS_CONSUMED
    100   gEfiAuthenticationInfoProtocolGuid            # PROTOCOL ALWAYS_CONSUMED 
     89  gEfiAcpiTableProtocolGuid                     ## SOMETIMES_CONSUMES ## SystemTable
     90  gEfiDriverBindingProtocolGuid                 ## SOMETIMES_PRODUCES
     91  gEfiPciIoProtocolGuid                         ## SOMETIMES_CONSUMES
     92  gEfiDhcp4ProtocolGuid                         ## TO_START
     93  gEfiDhcp6ProtocolGuid                         ## TO_START 
     94  gEfiDhcp4ServiceBindingProtocolGuid           ## TO_START
     95  gEfiDhcp6ServiceBindingProtocolGuid           ## TO_START 
     96  gEfiTcp4ProtocolGuid                          ## TO_START
     97  gEfiTcp6ProtocolGuid                          ## TO_START 
     98  gEfiTcp4ServiceBindingProtocolGuid            ## TO_START
     99  gEfiTcp6ServiceBindingProtocolGuid            ## TO_START 
     100  gEfiExtScsiPassThruProtocolGuid               ## BY_START
     101  gEfiHiiConfigAccessProtocolGuid               ## PRODUCES
     102  ## TO_START
     103  ## PRODUCES
     104  gEfiDevicePathProtocolGuid
     105  ## PRODUCES
     106  ## UNDEFINED # Variable
     107  gEfiIScsiInitiatorNameProtocolGuid
     108  ## PRODUCES       
     109  gEfiAuthenticationInfoProtocolGuid           
    101110
    102111[Guids]
    103   gEfiEventExitBootServicesGuid
    104   gEfiIfrTianoGuid                              ## CONSUMES ## GUID
    105   gEfiAcpiTableGuid                             ## CONSUMES ## GUID
    106   gEfiAcpi10TableGuid                           ## CONSUMES ## GUID
    107   gEfiAcpi20TableGuid                           ## CONSUMES ## GUID
    108   gIScsiConfigGuid                              ## PRODUCES ## GUID
     112  gEfiEventExitBootServicesGuid                 ## SOMETIMES_CONSUMES ## Event
     113  gEfiIfrTianoGuid                              ## SOMETIMES_PRODUCES ## UNDEFINED
     114  gEfiAcpiTableGuid                             ## SOMETIMES_CONSUMES ## SystemTable
     115  gEfiAcpi10TableGuid                           ## SOMETIMES_CONSUMES ## SystemTable
     116  gEfiAcpi20TableGuid                           ## SOMETIMES_CONSUMES ## SystemTable
     117 
     118  ## SOMETIMES_PRODUCES ## Variable:L"AttemptOrder"
     119  ## SOMETIMES_CONSUMES ## Variable:L"AttemptOrder"
     120  ## SOMETIMES_CONSUMES ## UNDEFINED # HiiIsConfigHdrMatch   mVendorStorageName
     121  ## SOMETIMES_PRODUCES ## UNDEFINED # HiiConstructConfigHdr mVendorStorageName
     122  ## SOMETIMES_PRODUCES ## UNDEFINED # HiiGetBrowserData     mVendorStorageName
     123  ## SOMETIMES_CONSUMES ## UNDEFINED # HiiSetBrowserData     mVendorStorageName
     124  ## SOMETIMES_CONSUMES ## HII
     125  gIScsiConfigGuid
     126 
     127[UserExtensions.TianoCore."ExtraFiles"]
     128  IScsiDxeExtra.uni
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/IScsiDxe/IScsiExtScsiPassThru.c

    r48674 r58459  
    22  The implementation of EFI_EXT_SCSI_PASS_THRU_PROTOCOL.
    33
    4 Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    8787  )
    8888{
     89  EFI_STATUS         Status;
     90  ISCSI_DRIVER_DATA  *Private;
     91 
    8992  if (Target[0] != 0) {
    9093    return EFI_INVALID_PARAMETER;
     
    9598  }
    9699
    97   return IScsiExecuteScsiCommand (This, Target, Lun, Packet);
     100  Status = IScsiExecuteScsiCommand (This, Target, Lun, Packet);
     101  if ((Status != EFI_SUCCESS) && (Status != EFI_NOT_READY)) {
     102    //
     103    // Try to reinstate the session and re-execute the Scsi command.
     104    //
     105    Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This);
     106    if (EFI_ERROR (IScsiSessionReinstatement (Private->Session))) {
     107      return EFI_DEVICE_ERROR;
     108    }
     109
     110    Status = IScsiExecuteScsiCommand (This, Target, Lun, Packet);
     111  }
     112
     113  return Status;
    98114}
    99115
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/IScsiDxe/IScsiIbft.c

    r48674 r58459  
    22  Implementation for iSCSI Boot Firmware Table publication.
    33
    4 Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    311311      // Map the various v4 addresses into v6 addresses.
    312312      //
    313       IScsiMapV4ToV6Addr (&NvData->LocalIp, &Nic->Ip);
    314       IScsiMapV4ToV6Addr (&NvData->Gateway, &Nic->Gateway);
     313      IScsiMapV4ToV6Addr (&NvData->LocalIp.v4, &Nic->Ip);
     314      IScsiMapV4ToV6Addr (&NvData->Gateway.v4, &Nic->Gateway);
    315315      IScsiMapV4ToV6Addr (&Attempt->PrimaryDns.v4, &Nic->PrimaryDns);
    316316      IScsiMapV4ToV6Addr (&Attempt->SecondaryDns.v4, &Nic->SecondaryDns);
     
    318318
    319319    } else if (NvData->IpMode == IP_MODE_IP6 || NvData->IpMode == IP_MODE_AUTOCONFIG) {
    320       //
    321       // TODO: The subnet mask/local ip/gateway/dhcpserver for iBFT-IPv6 needs to be
    322       // confirmed with spec owner.
    323       //
    324 
     320
     321      Nic->SubnetMaskPrefixLength = NvData->PrefixLength;
     322      CopyMem (&Nic->Ip, &NvData->LocalIp, sizeof (EFI_IPv6_ADDRESS));
     323      CopyMem (&Nic->Gateway, &NvData->Gateway, sizeof (EFI_IPv6_ADDRESS));
    325324      CopyMem (&Nic->PrimaryDns, &Attempt->PrimaryDns, sizeof (EFI_IPv6_ADDRESS));
    326325      CopyMem (&Nic->SecondaryDns, &Attempt->SecondaryDns, sizeof (EFI_IPv6_ADDRESS));
    327       //
    328       // TODO: DHCP server address cannot be retrieved by DHCPv6 process since
    329       // DHCP server option is removed.
    330       //CopyMem (&Nic->DhcpServer, &Attempt->DhcpServer, sizeof (EFI_IPv6_ADDRESS));
    331       //
     326      CopyMem (&Nic->DhcpServer, &Attempt->DhcpServer, sizeof (EFI_IPv6_ADDRESS));
     327
    332328    } else {
    333329      ASSERT (FALSE);
     
    364360
    365361    if (Attempt->AuthenticationType == ISCSI_AUTH_TYPE_CHAP) {
    366       Target->CHAPType          = AuthConfig->CHAPType;
     362      if (AuthConfig->CHAPType == ISCSI_CHAP_UNI) {
     363        Target->CHAPType = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_CHAP;
     364      } else if (AuthConfig->CHAPType == ISCSI_CHAP_MUTUAL) {
     365        Target->CHAPType = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_MUTUAL_CHAP;
     366      }
    367367    } else if (Attempt->AuthenticationType == ISCSI_AUTH_TYPE_NONE) {
    368       Target->CHAPType          = ISCSI_AUTH_TYPE_NONE;
     368      Target->CHAPType = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_NO_CHAP;
    369369    }
    370370
     
    407407      Target->CHAPSecretOffset  = (UINT16) ((UINTN) *Heap - (UINTN) Table);
    408408
    409       if (Target->CHAPType == ISCSI_CHAP_MUTUAL) {
     409      if (Target->CHAPType == EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_MUTUAL_CHAP) {
    410410        //
    411411        // Reverse CHAP Name.
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/IScsiDxe/IScsiImpl.h

    r48674 r58459  
    22  The shared head file for iSCSI driver.
    33
    4 Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    2424#include <Protocol/HiiConfigAccess.h>
    2525
     26#include <Protocol/Ip6.h>
    2627#include <Protocol/Dhcp4.h>
    2728#include <Protocol/Dhcp6.h>
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/IScsiDxe/IScsiMisc.c

    r48674 r58459  
    22  Miscellaneous routines for iSCSI driver.
    33
    4 Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    210210
    211211    if ((Lun[2 * Index] | Lun[2 * Index + 1]) == 0) {
    212       StrCpy (TempStr, L"0-");
     212      CopyMem (TempStr, L"0-", sizeof (L"0-"));
    213213    } else {
    214214      TempStr[0]  = (CHAR16) IScsiHexString[Lun[2 * Index] >> 4];
     
    224224    TempStr += StrLen (TempStr);
    225225  }
    226 
     226  //
     227  // Remove the last '-'
     228  //
     229  ASSERT (StrLen(Str) >= 1);
    227230  Str[StrLen (Str) - 1] = 0;
    228231
     
    891894}
    892895
     896/**
     897  Check wheather the Controller handle is configured to use DHCP protocol.
     898
     899  @param[in]  Controller           The handle of the controller.
     900  @param[in]  IpVersion            IP_VERSION_4 or IP_VERSION_6.
     901 
     902  @retval TRUE                     The handle of the controller need the Dhcp protocol.
     903  @retval FALSE                    The handle of the controller does not need the Dhcp protocol.
     904 
     905**/
     906BOOLEAN
     907IScsiDhcpIsConfigured (
     908  IN EFI_HANDLE  Controller,
     909  IN UINT8       IpVersion
     910  )
     911{
     912  ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptTmp;
     913  UINT8                       *AttemptConfigOrder;
     914  UINTN                       AttemptConfigOrderSize;
     915  UINTN                       Index;
     916  EFI_STATUS                  Status;
     917  EFI_MAC_ADDRESS             MacAddr;
     918  UINTN                       HwAddressSize;
     919  UINT16                      VlanId;
     920  CHAR16                      MacString[ISCSI_MAX_MAC_STRING_LEN];
     921  CHAR16                      AttemptName[ISCSI_NAME_IFR_MAX_SIZE];
     922 
     923  AttemptConfigOrder = IScsiGetVariableAndSize (
     924                         L"AttemptOrder",
     925                         &gIScsiConfigGuid,
     926                         &AttemptConfigOrderSize
     927                         );
     928  if (AttemptConfigOrder == NULL || AttemptConfigOrderSize == 0) {
     929    return FALSE;
     930  }
     931 
     932  //
     933  // Get MAC address of this network device.
     934  //
     935  Status = NetLibGetMacAddress (Controller, &MacAddr, &HwAddressSize);
     936  if(EFI_ERROR (Status)) {
     937    return FALSE;
     938  }
     939  //
     940  // Get VLAN ID of this network device.
     941  //
     942  VlanId = NetLibGetVlanId (Controller);
     943  IScsiMacAddrToStr (&MacAddr, (UINT32) HwAddressSize, VlanId, MacString);
     944 
     945  for (Index = 0; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) {
     946    UnicodeSPrint (
     947      AttemptName,
     948      (UINTN) 128,
     949      L"%s%d",
     950      MacString,
     951      (UINTN) AttemptConfigOrder[Index]
     952      );
     953    Status = GetVariable2 (
     954               AttemptName,
     955               &gEfiIScsiInitiatorNameProtocolGuid,
     956               (VOID**)&AttemptTmp,
     957               NULL
     958               );
     959    if(AttemptTmp == NULL || EFI_ERROR (Status)) {
     960      continue;
     961    }
     962   
     963    ASSERT (AttemptConfigOrder[Index] == AttemptTmp->AttemptConfigIndex);
     964
     965    if (AttemptTmp->SessionConfigData.Enabled == ISCSI_DISABLED) {
     966      FreePool (AttemptTmp);
     967      continue;
     968    }
     969
     970    if (AttemptTmp->SessionConfigData.IpMode != IP_MODE_AUTOCONFIG &&
     971        AttemptTmp->SessionConfigData.IpMode != ((IpVersion == IP_VERSION_4) ? IP_MODE_IP4 : IP_MODE_IP6)) {
     972      FreePool (AttemptTmp);
     973      continue;
     974    }
     975   
     976    if(AttemptTmp->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG ||
     977       AttemptTmp->SessionConfigData.InitiatorInfoFromDhcp == TRUE ||
     978       AttemptTmp->SessionConfigData.TargetInfoFromDhcp == TRUE) {
     979      FreePool (AttemptTmp);
     980      FreePool (AttemptConfigOrder);
     981      return TRUE;
     982    }
     983
     984    FreePool (AttemptTmp);
     985  }
     986 
     987  FreePool (AttemptConfigOrder);
     988  return FALSE;
     989}
    893990
    894991/**
     
    10771174      );
    10781175
    1079     AttemptConfigData = (ISCSI_ATTEMPT_CONFIG_NVDATA *) GetVariable (
    1080                                                           mPrivate->PortString,
    1081                                                           &gEfiIScsiInitiatorNameProtocolGuid
    1082                                                           );
     1176    GetVariable2 (
     1177                 mPrivate->PortString,
     1178                 &gEfiIScsiInitiatorNameProtocolGuid,
     1179                 (VOID**)&AttemptConfigData,
     1180                 NULL
     1181                 );
    10831182
    10841183    if (AttemptConfigData == NULL) {
     
    13411440  }
    13421441}
     1442
     1443/**
     1444  Tests whether a controller handle is being managed by IScsi driver.
     1445
     1446  This function tests whether the driver specified by DriverBindingHandle is
     1447  currently managing the controller specified by ControllerHandle.  This test
     1448  is performed by evaluating if the the protocol specified by ProtocolGuid is
     1449  present on ControllerHandle and is was opened by DriverBindingHandle and Nic
     1450  Device handle with an attribute of EFI_OPEN_PROTOCOL_BY_DRIVER.
     1451  If ProtocolGuid is NULL, then ASSERT().
     1452
     1453  @param  ControllerHandle     A handle for a controller to test.
     1454  @param  DriverBindingHandle  Specifies the driver binding handle for the
     1455                               driver.
     1456  @param  ProtocolGuid         Specifies the protocol that the driver specified
     1457                               by DriverBindingHandle opens in its Start()
     1458                               function.
     1459
     1460  @retval EFI_SUCCESS          ControllerHandle is managed by the driver
     1461                               specified by DriverBindingHandle.
     1462  @retval EFI_UNSUPPORTED      ControllerHandle is not managed by the driver
     1463                               specified by DriverBindingHandle.
     1464
     1465**/
     1466EFI_STATUS
     1467EFIAPI
     1468IScsiTestManagedDevice (
     1469  IN  EFI_HANDLE       ControllerHandle,
     1470  IN  EFI_HANDLE       DriverBindingHandle,
     1471  IN  EFI_GUID         *ProtocolGuid
     1472  )
     1473{
     1474  EFI_STATUS     Status;
     1475  VOID           *ManagedInterface;
     1476  EFI_HANDLE     NicControllerHandle;
     1477
     1478  ASSERT (ProtocolGuid != NULL);
     1479
     1480  NicControllerHandle = NetLibGetNicHandle (ControllerHandle, ProtocolGuid);
     1481  if (NicControllerHandle == NULL) {
     1482    return EFI_UNSUPPORTED;
     1483  }
     1484
     1485  Status = gBS->OpenProtocol (
     1486                  ControllerHandle,
     1487                  (EFI_GUID *) ProtocolGuid,
     1488                  &ManagedInterface,
     1489                  DriverBindingHandle,
     1490                  NicControllerHandle,
     1491                  EFI_OPEN_PROTOCOL_BY_DRIVER
     1492                  );
     1493  if (!EFI_ERROR (Status)) {
     1494    gBS->CloseProtocol (
     1495           ControllerHandle,
     1496           (EFI_GUID *) ProtocolGuid,
     1497           DriverBindingHandle,
     1498           NicControllerHandle
     1499           );
     1500    return EFI_UNSUPPORTED;
     1501  }
     1502
     1503  if (Status != EFI_ALREADY_STARTED) {
     1504    return EFI_UNSUPPORTED;
     1505  }
     1506
     1507  return EFI_SUCCESS;
     1508}
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/IScsiDxe/IScsiMisc.h

    r48674 r58459  
    22  Miscellaneous definitions for iSCSI driver.
    33
    4 Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    2424  UINT8             IpMode;
    2525
    26   EFI_IPv4_ADDRESS  LocalIp;
     26  EFI_IP_ADDRESS    LocalIp;
    2727  EFI_IPv4_ADDRESS  SubnetMask;
    28   EFI_IPv4_ADDRESS  Gateway;
     28  EFI_IP_ADDRESS    Gateway;
    2929
    3030  BOOLEAN           InitiatorInfoFromDhcp;
     
    3232  CHAR8             TargetName[ISCSI_NAME_MAX_SIZE];
    3333  EFI_IP_ADDRESS    TargetIp;
     34  UINT8             PrefixLength;
    3435  UINT8             BootLun[8];
    3536
     
    299300
    300301/**
     302  Check wheather the Controller handle is configured to use DHCP protocol.
     303
     304  @param[in]  Controller           The handle of the controller.
     305  @param[in]  IpVersion            IP_VERSION_4 or IP_VERSION_6.
     306 
     307  @retval TRUE                     The handle of the controller need the Dhcp protocol.
     308  @retval FALSE                    The handle of the controller does not need the Dhcp protocol.
     309 
     310**/
     311BOOLEAN
     312IScsiDhcpIsConfigured (
     313  IN EFI_HANDLE  Controller,
     314  IN UINT8       IpVersion
     315  );
     316
     317/**
    301318  Get the various configuration data of this iSCSI instance.
    302319
     
    341358  );
    342359
     360/**
     361  Tests whether a controller handle is being managed by IScsi driver.
     362
     363  This function tests whether the driver specified by DriverBindingHandle is
     364  currently managing the controller specified by ControllerHandle.  This test
     365  is performed by evaluating if the the protocol specified by ProtocolGuid is
     366  present on ControllerHandle and is was opened by DriverBindingHandle and Nic
     367  Device handle with an attribute of EFI_OPEN_PROTOCOL_BY_DRIVER.
     368  If ProtocolGuid is NULL, then ASSERT().
     369
     370  @param  ControllerHandle     A handle for a controller to test.
     371  @param  DriverBindingHandle  Specifies the driver binding handle for the
     372                               driver.
     373  @param  ProtocolGuid         Specifies the protocol that the driver specified
     374                               by DriverBindingHandle opens in its Start()
     375                               function.
     376
     377  @retval EFI_SUCCESS          ControllerHandle is managed by the driver
     378                               specified by DriverBindingHandle.
     379  @retval EFI_UNSUPPORTED      ControllerHandle is not managed by the driver
     380                               specified by DriverBindingHandle.
     381
     382**/
     383EFI_STATUS
     384EFIAPI
     385IScsiTestManagedDevice (
     386  IN  EFI_HANDLE       ControllerHandle,
     387  IN  EFI_HANDLE       DriverBindingHandle,
     388  IN  EFI_GUID         *ProtocolGuid
     389  );
    343390#endif
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/IScsiDxe/IScsiProto.c

    r48674 r58459  
    22  The implementation of iSCSI protocol based on RFC3720.
    33
    4 Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    229229  Conn->ParamNegotiated = FALSE;
    230230  Conn->Cid             = Session->NextCid++;
    231   Conn->Ipv6Flag        = mPrivate->Ipv6Flag;
     231  Conn->Ipv6Flag        = NvData->IpMode == IP_MODE_IP6 || Session->ConfigData->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP6;
    232232
    233233  Status = gBS->CreateEvent (
     
    260260    CopyMem (&Tcp4IoConfig->RemoteIp, &NvData->TargetIp, sizeof (EFI_IPv4_ADDRESS));
    261261
    262     Tcp4IoConfig->RemotePort = NvData->TargetPort;
    263     Tcp4IoConfig->ActiveFlag = TRUE;
    264 
     262    Tcp4IoConfig->RemotePort  = NvData->TargetPort;
     263    Tcp4IoConfig->ActiveFlag  = TRUE;
     264    Tcp4IoConfig->StationPort = 0;
    265265  } else {
    266266    Tcp6IoConfig = &TcpIoConfig.Tcp6IoConfigData;
    267267 
    268268    CopyMem (&Tcp6IoConfig->RemoteIp, &NvData->TargetIp, sizeof (EFI_IPv6_ADDRESS));
    269     Tcp6IoConfig->RemotePort = NvData->TargetPort;
    270     Tcp6IoConfig->ActiveFlag = TRUE;
     269    Tcp6IoConfig->RemotePort  = NvData->TargetPort;
     270    Tcp6IoConfig->ActiveFlag  = TRUE;
     271    Tcp6IoConfig->StationPort = 0;
    271272  }
    272273
     
    309310}
    310311
     312/**
     313  Retrieve the IPv6 Address/Prefix/Gateway from the established TCP connection, these informations
     314  will be filled in the iSCSI Boot Firmware Table.
     315
     316  @param[in]  Conn             The connection used in the iSCSI login phase.
     317
     318  @retval     EFI_SUCCESS      Get the NIC information successfully.
     319  @retval     Others           Other errors as indicated.
     320 
     321**/
     322EFI_STATUS
     323IScsiGetIp6NicInfo (
     324  IN ISCSI_CONNECTION  *Conn
     325  )
     326{
     327  ISCSI_SESSION_CONFIG_NVDATA  *NvData;
     328  EFI_TCP6_PROTOCOL            *Tcp6;
     329  EFI_IP6_MODE_DATA            Ip6ModeData;
     330  EFI_STATUS                   Status;
     331  EFI_IPv6_ADDRESS             *TargetIp;
     332  UINTN                        Index;
     333  UINT8                        SubnetPrefixLength;
     334  UINTN                        RouteEntry;
     335
     336  NvData   = &Conn->Session->ConfigData->SessionConfigData;
     337  TargetIp = &NvData->TargetIp.v6;
     338  Tcp6     = Conn->TcpIo.Tcp.Tcp6;
     339
     340  ZeroMem (&Ip6ModeData, sizeof (EFI_IP6_MODE_DATA));
     341  Status = Tcp6->GetModeData (
     342                   Tcp6,
     343                   NULL,
     344                   NULL,
     345                   &Ip6ModeData,
     346                   NULL,
     347                   NULL
     348                   );
     349  if (EFI_ERROR (Status)) {
     350    return Status;
     351  }
     352
     353  if (!Ip6ModeData.IsConfigured) {
     354    Status = EFI_ABORTED;
     355    goto ON_EXIT;
     356  }
     357
     358  IP6_COPY_ADDRESS (&NvData->LocalIp, &Ip6ModeData.ConfigData.StationAddress);
     359
     360  NvData->PrefixLength = 0;
     361  for (Index = 0; Index < Ip6ModeData.AddressCount; Index++) {
     362    if (EFI_IP6_EQUAL (&NvData->LocalIp.v6, &Ip6ModeData.AddressList[Index].Address)) {
     363      NvData->PrefixLength = Ip6ModeData.AddressList[Index].PrefixLength;
     364      break;
     365    }
     366  }
     367
     368  SubnetPrefixLength = 0;
     369  RouteEntry = Ip6ModeData.RouteCount;
     370  for (Index = 0; Index < Ip6ModeData.RouteCount; Index++) {
     371    if (NetIp6IsNetEqual (TargetIp, &Ip6ModeData.RouteTable[Index].Destination, Ip6ModeData.RouteTable[Index].PrefixLength)) {
     372      if (SubnetPrefixLength < Ip6ModeData.RouteTable[Index].PrefixLength) {
     373        SubnetPrefixLength = Ip6ModeData.RouteTable[Index].PrefixLength;
     374        RouteEntry = Index;
     375      }
     376    }
     377  }
     378  if (RouteEntry != Ip6ModeData.RouteCount) {
     379    IP6_COPY_ADDRESS (&NvData->Gateway, &Ip6ModeData.RouteTable[RouteEntry].Gateway);
     380  }
     381
     382ON_EXIT:
     383  if (Ip6ModeData.AddressList != NULL) {
     384    FreePool (Ip6ModeData.AddressList);
     385  }
     386  if (Ip6ModeData.GroupTable!= NULL) {
     387    FreePool (Ip6ModeData.GroupTable);
     388  }
     389  if (Ip6ModeData.RouteTable!= NULL) {
     390    FreePool (Ip6ModeData.RouteTable);
     391  }
     392  if (Ip6ModeData.NeighborCache!= NULL) {
     393    FreePool (Ip6ModeData.NeighborCache);
     394  }
     395  if (Ip6ModeData.PrefixTable!= NULL) {
     396    FreePool (Ip6ModeData.PrefixTable);
     397  }
     398  if (Ip6ModeData.IcmpTypeList!= NULL) {
     399    FreePool (Ip6ModeData.IcmpTypeList);
     400  }
     401
     402  return Status;
     403}
    311404
    312405/**
     
    380473    Session->State = SESSION_STATE_LOGGED_IN;
    381474
    382     if (!mPrivate->Ipv6Flag) {
     475    if (!Conn->Ipv6Flag) {
    383476      ProtocolGuid = &gEfiTcp4ProtocolGuid;     
    384477    } else {
     
    396489
    397490    ASSERT_EFI_ERROR (Status);
     491
     492    if (Conn->Ipv6Flag) {
     493      Status = IScsiGetIp6NicInfo (Conn);
     494    }
    398495  }
    399496
     
    507604  EFI_STATUS  Status;
    508605  NET_BUF     *Pdu;
     606
     607  Pdu = NULL;
    509608
    510609  //
     
    27242823  @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
    27252824  @retval EFI_PROTOCOL_ERROR   There is no such data in the net buffer.
     2825  @retval EFI_NOT_READY        The target can not accept new commands.
    27262826  @retval Others               Other errors as indicated.
    27272827
     
    27562856
    27572857  if (Session->State != SESSION_STATE_LOGGED_IN) {
    2758     return EFI_DEVICE_ERROR;
     2858    Status = EFI_DEVICE_ERROR;
     2859    goto ON_EXIT;
    27592860  }
    27602861
     
    29013002  }
    29023003
    2903   if ((Status != EFI_SUCCESS) && (Status != EFI_NOT_READY)) {
    2904     //
    2905     // Reinstate the session.
    2906     //
    2907     if (EFI_ERROR (IScsiSessionReinstatement (Session))) {
    2908       Status = EFI_DEVICE_ERROR;
    2909     }
    2910   }
    2911 
    29123004  return Status;
    29133005}
     
    29303022  EFI_STATUS    Status;
    29313023
    2932   ASSERT (Session->State == SESSION_STATE_LOGGED_IN);
     3024  ASSERT (Session->State != SESSION_STATE_FREE);
    29333025
    29343026  //
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/IScsiDxe/IScsiProto.h

    r48674 r58459  
    22  The header file of iSCSI Protocol that defines many specific data structures.
    33
    4 Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
    55This program and the accompanying materials
    66are licensed and made available under the terms and conditions of the BSD License
     
    983983  @retval EFI_DEVICE_ERROR     Session state was not as required.
    984984  @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
     985  @retval EFI_NOT_READY        The target can not accept new commands.
    985986  @retval Others               Other errors as indicated.
    986987
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Ip6Dxe/ComponentName.c

    r48674 r58459  
    33  EFI_COMPONENT_NAME2_PROTOCOL protocol.
    44
    5   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     5  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    66
    77  This program and the accompanying materials
     
    174174  }
    175175};
     176
     177GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE      *gIp6ControllerNameTable = NULL;
    176178
    177179/**
     
    233235
    234236/**
     237  Update the component name for the IP6 child handle.
     238
     239  @param  Ip6[in]                   A pointer to the EFI_IP6_PROTOCOL.
     240
     241 
     242  @retval EFI_SUCCESS               Update the ControllerNameTable of this instance successfully.
     243  @retval EFI_INVALID_PARAMETER     The input parameter is invalid.
     244 
     245**/
     246EFI_STATUS
     247UpdateName (
     248  IN    EFI_IP6_PROTOCOL         *Ip6
     249  )
     250{
     251  EFI_STATUS                       Status;
     252  CHAR16                           HandleName[128];
     253  EFI_IP6_MODE_DATA                Ip6ModeData;
     254  UINTN                            Offset;
     255  CHAR16                           Address[sizeof"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"];
     256
     257  if (Ip6 == NULL) {
     258    return EFI_INVALID_PARAMETER;
     259  }
     260
     261  //
     262  // Format the child name into the string buffer.
     263  //
     264  Offset = 0;
     265  Status = Ip6->GetModeData (Ip6, &Ip6ModeData, NULL, NULL);
     266  if (!EFI_ERROR (Status) && Ip6ModeData.IsStarted) {
     267    Status = NetLibIp6ToStr (&Ip6ModeData.ConfigData.StationAddress, Address, sizeof(Address));
     268    if (EFI_ERROR (Status)) {
     269      return Status;
     270    }
     271    Offset += UnicodeSPrint (
     272                HandleName,
     273                sizeof(HandleName),
     274                L"IPv6(StationAddress=%s, ",
     275                Address
     276                );
     277    Status = NetLibIp6ToStr (&Ip6ModeData.ConfigData.DestinationAddress, Address, sizeof(Address));
     278    if (EFI_ERROR (Status)) {
     279      return Status;
     280    }
     281    UnicodeSPrint (
     282      HandleName + Offset,
     283      sizeof(HandleName) - Offset * sizeof (CHAR16),
     284      L"DestinationAddress=%s)",
     285      Address
     286      );
     287  } else if (!Ip6ModeData.IsStarted) {
     288    UnicodeSPrint (HandleName, sizeof(HandleName), L"IPv6(Not started)");
     289  } else {
     290    UnicodeSPrint (HandleName, sizeof(HandleName), L"IPv6(%r)", Status);
     291  }
     292
     293  if (gIp6ControllerNameTable != NULL) {
     294      FreeUnicodeStringTable (gIp6ControllerNameTable);
     295      gIp6ControllerNameTable = NULL;
     296  }
     297 
     298  Status = AddUnicodeString2 (
     299             "eng",
     300             gIp6ComponentName.SupportedLanguages,
     301             &gIp6ControllerNameTable,
     302             HandleName,
     303             TRUE
     304             );
     305  if (EFI_ERROR (Status)) {
     306    return Status;
     307  }
     308 
     309  return AddUnicodeString2 (
     310           "en",
     311           gIp6ComponentName2.SupportedLanguages,
     312           &gIp6ControllerNameTable,
     313           HandleName,
     314           FALSE
     315           );
     316}
     317
     318/**
    235319  Retrieves a Unicode string that is the user-readable name of the controller
    236320  that is being managed by a driver.
     
    310394  )
    311395{
    312   return EFI_UNSUPPORTED;
     396  EFI_STATUS                    Status;
     397  EFI_IP6_PROTOCOL              *Ip6;
     398 
     399  //
     400  // Only provide names for child handles.
     401  //
     402  if (ChildHandle == NULL) {
     403    return EFI_UNSUPPORTED;
     404  }
     405
     406  //
     407  // Make sure this driver produced ChildHandle
     408  //
     409  Status = EfiTestChildHandle (
     410             ControllerHandle,
     411             ChildHandle,
     412             &gEfiManagedNetworkProtocolGuid
     413             );
     414  if (EFI_ERROR (Status)) {
     415    return Status;
     416  }
     417
     418  //
     419  // Retrieve an instance of a produced protocol from ChildHandle
     420  //
     421  Status = gBS->OpenProtocol (
     422                  ChildHandle,
     423                  &gEfiIp6ProtocolGuid,
     424                  (VOID **)&Ip6,
     425                  NULL,
     426                  NULL,
     427                  EFI_OPEN_PROTOCOL_GET_PROTOCOL
     428                  );
     429  if (EFI_ERROR (Status)) {
     430    return Status;
     431  }
     432
     433  //
     434  // Update the component name for this child handle.
     435  //
     436  Status = UpdateName (Ip6);
     437  if (EFI_ERROR (Status)) {
     438    return Status;
     439  }
     440
     441  return LookupUnicodeString2 (
     442           Language,
     443           This->SupportedLanguages,
     444           gIp6ControllerNameTable,
     445           ControllerName,
     446           (BOOLEAN)(This == &gIp6ComponentName)
     447           );
    313448}
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Ip6Dxe/Ip6Common.c

    r48674 r58459  
    22  The implementation of common functions shared by IP6 driver.
    33
    4   Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    330330
    331331/**
     332  Callback function which provided by user to remove one node in NetDestroyLinkList process.
     333 
     334  @param[in]    Entry           The entry to be removed.
     335  @param[in]    Context         Pointer to the callback context corresponds to the Context in NetDestroyLinkList.
     336
     337  @retval EFI_SUCCESS           The entry has been removed successfully.
     338  @retval Others                Fail to remove the entry.
     339
     340**/
     341EFI_STATUS
     342EFIAPI
     343Ip6DestroyChildEntryByAddr (
     344  IN LIST_ENTRY         *Entry,
     345  IN VOID               *Context
     346  )
     347{
     348  IP6_PROTOCOL                  *Instance;
     349  EFI_SERVICE_BINDING_PROTOCOL  *ServiceBinding;
     350  EFI_IPv6_ADDRESS              *Address;
     351 
     352  Instance = NET_LIST_USER_STRUCT_S (Entry, IP6_PROTOCOL, Link, IP6_PROTOCOL_SIGNATURE);
     353  ServiceBinding = ((IP6_DESTROY_CHILD_BY_ADDR_CALLBACK_CONTEXT*) Context)->ServiceBinding;
     354  Address = ((IP6_DESTROY_CHILD_BY_ADDR_CALLBACK_CONTEXT*) Context)->Address;
     355
     356  if ((Instance->State == IP6_STATE_CONFIGED) && EFI_IP6_EQUAL (&Instance->ConfigData.StationAddress, Address)) {
     357    return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);
     358  }
     359 
     360  return EFI_SUCCESS;
     361}
     362
     363/**
    332364  Destroy the IP instance if its StationAddress is removed. It is the help function
    333365  for Ip6RemoveAddr().
     
    343375  )
    344376{
    345   BOOLEAN                       OneDestroyed;
    346   EFI_SERVICE_BINDING_PROTOCOL  *ServiceBinding;
    347   LIST_ENTRY                    *Entry;
    348   IP6_PROTOCOL                  *Instance;
     377  LIST_ENTRY                    *List;
     378  IP6_DESTROY_CHILD_BY_ADDR_CALLBACK_CONTEXT  Context;
    349379
    350380  NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
    351381
    352   ServiceBinding = &IpSb->ServiceBinding;
    353 
    354   //
    355   // Upper layer IP protocol consumers may have tight relationship between several
    356   // IP protocol instances, in other words, calling ServiceBinding->DestroyChild to
    357   // destroy one IP child may cause other related IP children destroyed too. This
    358   // will probably leave hole in the children list when we iterate it. So everytime
    359   // we just destroy one child then back to the start point to iterate the list.
    360   //
    361   do {
    362     OneDestroyed = FALSE;
    363 
    364     NET_LIST_FOR_EACH (Entry, &IpSb->Children) {
    365       Instance = NET_LIST_USER_STRUCT_S (Entry, IP6_PROTOCOL, Link, IP6_PROTOCOL_SIGNATURE);
    366 
    367       if ((Instance->State == IP6_STATE_CONFIGED) && EFI_IP6_EQUAL (&Instance->ConfigData.StationAddress, Address)) {
    368         ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);
    369         OneDestroyed = TRUE;
    370         break;
    371       }
    372     }
    373   } while (OneDestroyed);
     382  List = &IpSb->Children;
     383  Context.ServiceBinding = &IpSb->ServiceBinding;
     384  Context.Address = Address;
     385  NetDestroyLinkList (
     386    List,
     387    Ip6DestroyChildEntryByAddr,
     388    &Context,
     389    NULL
     390    );
    374391}
    375392
     
    635652
    636653/**
    637   Set the Ip6 variable data.
    638 
    639   @param[in]  IpSb              Points to an IP6 service binding instance.
    640 
    641   @retval EFI_OUT_OF_RESOURCES  There are not enough resources to set the variable.
    642   @retval other                 Set variable failed.
    643 
    644 **/
    645 EFI_STATUS
    646 Ip6SetVariableData (
    647   IN IP6_SERVICE  *IpSb
    648   )
    649 {
    650   UINT32                 NumConfiguredInstance;
    651   LIST_ENTRY             *Entry;
    652   UINTN                  VariableDataSize;
    653   EFI_IP6_VARIABLE_DATA  *Ip6VariableData;
    654   EFI_IP6_ADDRESS_PAIR   *Ip6AddressPair;
    655   IP6_PROTOCOL           *IpInstance;
    656   CHAR16                 *NewMacString;
    657   EFI_STATUS             Status;
    658 
    659   NumConfiguredInstance = 0;
    660 
    661   //
    662   // Go through the children list to count the configured children.
    663   //
    664   NET_LIST_FOR_EACH (Entry, &IpSb->Children) {
    665     IpInstance = NET_LIST_USER_STRUCT_S (Entry, IP6_PROTOCOL, Link, IP6_PROTOCOL_SIGNATURE);
    666 
    667     if (IpInstance->State == IP6_STATE_CONFIGED) {
    668       NumConfiguredInstance++;
    669     }
    670   }
    671 
    672   //
    673   // Calculate the size of the Ip6VariableData. As there may be no IP child,
    674   // we should add extra buffer for the address paris only if the number of configured
    675   // children is more than 1.
    676   //
    677   VariableDataSize = sizeof (EFI_IP6_VARIABLE_DATA);
    678 
    679   if (NumConfiguredInstance > 1) {
    680     VariableDataSize += sizeof (EFI_IP6_ADDRESS_PAIR) * (NumConfiguredInstance - 1);
    681   }
    682 
    683   Ip6VariableData = AllocatePool (VariableDataSize);
    684   if (Ip6VariableData == NULL) {
    685     return EFI_OUT_OF_RESOURCES;
    686   }
    687 
    688   Ip6VariableData->DriverHandle = IpSb->Image;
    689   Ip6VariableData->AddressCount = NumConfiguredInstance;
    690 
    691   Ip6AddressPair                = &Ip6VariableData->AddressPairs[0];
    692 
    693   //
    694   // Go through the children list to fill the configured children's address pairs.
    695   //
    696   NET_LIST_FOR_EACH (Entry, &IpSb->Children) {
    697     IpInstance = NET_LIST_USER_STRUCT_S (Entry, IP6_PROTOCOL, Link, IP6_PROTOCOL_SIGNATURE);
    698 
    699     if (IpInstance->State == IP6_STATE_CONFIGED) {
    700       Ip6AddressPair->InstanceHandle = IpInstance->Handle;
    701       Ip6AddressPair->PrefixLength   = IpInstance->PrefixLength;
    702       IP6_COPY_ADDRESS (&Ip6AddressPair->Ip6Address, &IpInstance->ConfigData.StationAddress);
    703 
    704       Ip6AddressPair++;
    705     }
    706   }
    707 
    708   //
    709   // Get the mac string.
    710   //
    711   Status = NetLibGetMacString (IpSb->Controller, IpSb->Image, &NewMacString);
    712   if (EFI_ERROR (Status)) {
    713     goto Exit;
    714   }
    715 
    716   if (IpSb->MacString != NULL) {
    717     //
    718     // The variable is set already, we're going to update it.
    719     //
    720     if (StrCmp (IpSb->MacString, NewMacString) != 0) {
    721       //
    722       // The mac address is changed, delete the previous variable first.
    723       //
    724       gRT->SetVariable (
    725              IpSb->MacString,
    726              &gEfiIp6ServiceBindingProtocolGuid,
    727              EFI_VARIABLE_BOOTSERVICE_ACCESS,
    728              0,
    729              NULL
    730              );
    731     }
    732 
    733     FreePool (IpSb->MacString);
    734   }
    735 
    736   IpSb->MacString = NewMacString;
    737 
    738   Status = gRT->SetVariable (
    739                   IpSb->MacString,
    740                   &gEfiIp6ServiceBindingProtocolGuid,
    741                   EFI_VARIABLE_BOOTSERVICE_ACCESS,
    742                   VariableDataSize,
    743                   (VOID *) Ip6VariableData
    744                   );
    745 
    746 Exit:
    747   FreePool (Ip6VariableData);
    748   return Status;
    749 }
    750 
    751 /**
    752   Clear the variable and free the resource.
    753 
    754   @param[in]  IpSb                  Ip6 service binding instance.
    755 
    756 **/
    757 VOID
    758 Ip6ClearVariableData (
    759   IN IP6_SERVICE  *IpSb
    760   )
    761 {
    762   ASSERT (IpSb->MacString != NULL);
    763 
    764   gRT->SetVariable (
    765          IpSb->MacString,
    766          &gEfiIp6ServiceBindingProtocolGuid,
    767          EFI_VARIABLE_BOOTSERVICE_ACCESS,
    768          0,
    769          NULL
    770          );
    771 
    772   FreePool (IpSb->MacString);
    773   IpSb->MacString = NULL;
    774 }
    775 
    776 /**
    777654  Convert the multibyte field in IP header's byter order.
    778655  In spite of its name, it can also be used to convert from
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Ip6Dxe/Ip6Common.h

    r48674 r58459  
    22  Common definition and functions for IP6 driver.
    33
    4   Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    6060  Ip6AnyCast
    6161} IP6_ADDRESS_TYPE;
     62
     63typedef struct {
     64  EFI_SERVICE_BINDING_PROTOCOL  *ServiceBinding;
     65  EFI_IPv6_ADDRESS              *Address;
     66} IP6_DESTROY_CHILD_BY_ADDR_CALLBACK_CONTEXT;
    6267
    6368typedef struct _IP6_INTERFACE    IP6_INTERFACE;
     
    276281
    277282/**
    278   Set the Ip6 variable data.
    279 
    280   @param[in]  IpSb              Points to an IP6 service binding instance
    281 
    282   @retval EFI_OUT_OF_RESOURCES  There are not enough resources to set the variable.
    283   @retval other                 Set variable failed.
    284 
    285 **/
    286 EFI_STATUS
    287 Ip6SetVariableData (
    288   IN IP6_SERVICE  *IpSb
    289   );
    290 
    291 /**
    292   Clear the variable and free the resource.
    293 
    294   @param[in]  IpSb                  Ip6 service binding instance.
    295 
    296 **/
    297 VOID
    298 Ip6ClearVariableData (
    299   IN IP6_SERVICE  *IpSb
    300   );
    301 
    302 /**
    303283  Get the MAC address for a multicast IP address. Call
    304284  Mnp's McastIpToMac to find the MAC address instead of
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Ip6Dxe/Ip6Config.vfr

    r48674 r58459  
    128128      help   = STRING_TOKEN (STR_SAVE_CHANGES_HELP),
    129129      text   = STRING_TOKEN (STR_SAVE_CHANGES),
    130         text   = STRING_TOKEN (STR_NULL),
    131130      flags  = INTERACTIVE,
    132131      key    = KEY_SAVE_CHANGES;
     
    167166      help   = STRING_TOKEN (STR_SAVE_AND_EXIT),
    168167      text   = STRING_TOKEN (STR_SAVE_AND_EXIT),
    169         text   = STRING_TOKEN (STR_SAVE_AND_EXIT),
    170168      flags  = INTERACTIVE,
    171169      key    = KEY_SAVE_CONFIG_CHANGES;
     
    174172      help   = STRING_TOKEN (STR_NO_SAVE_AND_EXIT),
    175173      text   = STRING_TOKEN (STR_NO_SAVE_AND_EXIT),
    176         text   = STRING_TOKEN (STR_NO_SAVE_AND_EXIT),
    177174      flags  = INTERACTIVE,
    178175      key    = KEY_IGNORE_CONFIG_CHANGES;
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c

    r48674 r58459  
    22  The implementation of EFI IPv6 Configuration Protocol.
    33
    4   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    474474      DataRecord           = &Variable->DataRecord[Variable->DataRecordCount];
    475475      DataRecord->DataType = (EFI_IP6_CONFIG_DATA_TYPE) Index;
    476       DataRecord->DataSize = DataItem->DataSize;
     476      DataRecord->DataSize = (UINT32) DataItem->DataSize;
    477477      DataRecord->Offset   = (UINT16) (Heap - (CHAR8 *) Variable);
    478478
     
    23172317
    23182318/**
    2319   Destory the Dhcp6 child in IP6_CONFIG_INSTANCE and release the resources.
     2319  Destroy the Dhcp6 child in IP6_CONFIG_INSTANCE and release the resources.
    23202320
    23212321  @param[in, out] Instance    The buffer of IP6_CONFIG_INSTANCE to be freed.
    23222322
    23232323  @retval EFI_SUCCESS         The child was successfully destroyed.
    2324   @retval Others              Failed to destory the child.
     2324  @retval Others              Failed to destroy the child.
    23252325
    23262326**/
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.h

    r48674 r58459  
    22  Definitions for EFI IPv6 Configuartion Protocol implementation.
    33
    4   Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    130130typedef struct {
    131131  UINT16                    Offset;
    132   UINTN                     DataSize;
     132  UINT32                    DataSize;
    133133  EFI_IP6_CONFIG_DATA_TYPE  DataType;
    134134} IP6_CONFIG_DATA_RECORD;
     
    280280
    281281/**
    282   Destory the Dhcp6 child in IP6_CONFIG_INSTANCE and release the resources.
     282  Destroy the Dhcp6 child in IP6_CONFIG_INSTANCE and release the resources.
    283283
    284284  @param[in, out] Instance    The buffer of IP6_CONFIG_INSTANCE to be freed.
    285285
    286286  @retval EFI_SUCCESS         The child was successfully destroyed.
    287   @retval Others              Failed to destory the child.
     287  @retval Others              Failed to destroy the child.
    288288 
    289289**/
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Ip6Dxe/Ip6ConfigNv.c

    r48674 r58459  
    22  Helper functions for configuring or obtaining the parameters relating to IP6.
    33
    4   Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    601601  }
    602602
     603  ZeroMem (&AddressInfo, sizeof (EFI_IP6_ADDRESS_INFO));
    603604  LocalString = (CHAR16 *) AllocateCopyPool (StrSize (String), String);
    604605  if (LocalString == NULL) {
     
    670671/**
    671672  This function converts the interface info to string and draws it to the IP6 UI.
    672   The interface information includes interface name, interface type, hardware address,
    673   address info, and route table information. The address information is also used as the
    674   content of manual addresses in IP6 UI.
     673  The interface information includes interface name, interface type, hardware
     674  address and route table information.
    675675
    676676  @param[in]       IfInfo          The pointer of EFI_IP6_CONFIG_INTERFACE_INFO.
     
    694694  UINTN                          Number;
    695695  CHAR16                         *String;
    696   CHAR16                         *LinkLocalStr;
    697696  CHAR16                         PortString[ADDRESS_STR_MAX_SIZE];
    698697  CHAR16                         FormatString[8];
    699698  EFI_STRING_ID                  StringId;
    700   EFI_STATUS                     Status;
    701699
    702700  if ((IfInfo == NULL) || (HiiHandle == NULL) || (IfrNvData == NULL)) {
     
    721719  //
    722720  if (IfInfo->IfType == Ip6InterfaceTypeEthernet) {
    723     StrCpy (PortString, IP6_ETHERNET);
     721    CopyMem (PortString, IP6_ETHERNET, sizeof (IP6_ETHERNET));
    724722  } else if (IfInfo->IfType == Ip6InterfaceTypeExperimentalEthernet) {
    725     StrCpy (PortString, IP6_EXPERIMENTAL_ETHERNET);
     723    CopyMem (PortString, IP6_EXPERIMENTAL_ETHERNET, sizeof (IP6_EXPERIMENTAL_ETHERNET));
    726724  } else {
    727725    //
     
    750748
    751749    if (IfInfo->HwAddress.Addr[Index] < 0x10) {
    752       StrCpy (FormatString, L"0%x-");
     750      CopyMem (FormatString, L"0%x-", sizeof (L"0%x-"));
    753751    } else {
    754       StrCpy (FormatString, L"%x-");
     752      CopyMem (FormatString, L"%x-", sizeof (L"%x-"));
    755753    }
    756754
     
    783781  }
    784782
    785   //
    786   // Print the host address Information.
    787   //
    788   Status = Ip6ConvertAddressListToString (
    789              PortString,
    790              HiiHandle,
    791              Ip6ConfigNvHostAddress,
    792              IfInfo->AddressInfo,
    793              IfInfo->AddressInfoCount
    794              );
    795   if (EFI_ERROR (Status)) {
    796     return Status;
    797   }
    798 
    799   //
    800   // Copy the Host Address Info to manual address field.
    801   // Do not copy the link local address.
    802   //
    803   LinkLocalStr = StrStr (PortString, IP6_LINK_LOCAL_PREFIX);
    804   if (LinkLocalStr != NULL) {
    805     Number = LinkLocalStr - PortString;
    806     if (Number > 0) {
    807       CopyMem (IfrNvData->ManualAddress, PortString, Number * sizeof (CHAR16));
    808     }
    809 
    810     while ((*LinkLocalStr != L' ') && (*LinkLocalStr != L'\0')) {
    811       LinkLocalStr++;
    812     }
    813 
    814     if (*LinkLocalStr != L'\0') {
    815       LinkLocalStr++;
    816       StrCat (IfrNvData->ManualAddress, LinkLocalStr);
    817     }
    818   } else {
    819     StrCpy (IfrNvData->ManualAddress, PortString);
    820   }
    821 
    822   //
    823   // Print the route table information.
    824   //
    825   Status = Ip6ConvertAddressListToString (
    826              PortString,
    827              HiiHandle,
    828              Ip6ConfigNvRouteTable,
    829              IfInfo->RouteTable,
    830              IfInfo->RouteCount
    831              );
    832   return Status;
     783  return EFI_SUCCESS;
    833784}
    834785
     
    1034985  IfrNvData->DadTransmitCount = DadXmits.DupAddrDetectTransmits;
    1035986
    1036   //
    1037   // Get DNS server list.
    1038   //
    1039   FreePool (Data);
    1040   Data     = NULL;
    1041   DataSize = 0;
    1042   Status   = Ip6ConfigNvGetData (
    1043                Ip6Config,
    1044                Ip6ConfigDataTypeDnsServer,
    1045                &DataSize,
    1046                (VOID **) &Data
    1047                );
    1048 
    1049   if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
    1050     goto Exit;
    1051   }
    1052 
    1053   if (DataSize > 0) {
    1054     //
    1055     // Convert the DNS server address to string and draw it to UI.
    1056     //
    1057     Status = Ip6ConvertAddressListToString (
    1058                IfrNvData->DnsAddress,
    1059                HiiHandle,
    1060                Ip6ConfigNvDnsAddress,
    1061                Data,
    1062                DataSize / sizeof (EFI_IPv6_ADDRESS)
    1063                );
    1064     if (EFI_ERROR (Status)) {
    1065       goto Exit;
    1066     }
    1067 
    1068     FreePool (Data);
    1069     Data = NULL;
    1070   }
    1071 
    1072   //
    1073   // Get gateway adderss list.
    1074   //
    1075   DataSize = 0;
    1076   Status   = Ip6ConfigNvGetData (
    1077                Ip6Config,
    1078                Ip6ConfigDataTypeGateway,
    1079                &DataSize,
    1080                (VOID **) &Data
    1081                );
    1082 
    1083   if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
    1084     goto Exit;
    1085   }
    1086 
    1087   if (DataSize > 0) {
    1088     //
    1089     // Convert the gateway address to string and draw it to UI.
    1090     //
    1091     Status = Ip6ConvertAddressListToString (
    1092                IfrNvData->GatewayAddress,
    1093                HiiHandle,
    1094                Ip6ConfigNvGatewayAddress,
    1095                Data,
    1096                DataSize / sizeof (EFI_IPv6_ADDRESS)
    1097                );
    1098     if (EFI_ERROR (Status)) {
    1099       goto Exit;
    1100     }
    1101   }
    1102 
    1103   Status = EFI_SUCCESS;
    1104 
    1105987Exit:
    1106988  if (Data != NULL) {
     
    1113995/**
    1114996  Convert IFR data into IP6 configuration data. The policy, alternative interface
    1115   ID, and DAD transmit counts, and will be saved. If under manual policy, the configured
    1116   manual address, gateway address, and DNS server address will be saved.
     997  ID, and DAD transmit counts, and will be saved.
    1117998
    1118999  @param[in]       IfrNvData       The IFR NV data.
     
    11251006**/
    11261007EFI_STATUS
    1127 Ip6ConvertIfrNvDataToConfigNvData (
     1008Ip6ConvertIfrNvDataToConfigNvDataGeneral (
     1009  IN     IP6_CONFIG_IFR_NVDATA       *IfrNvData,
     1010  IN OUT IP6_CONFIG_INSTANCE         *Instance
     1011  )
     1012{
     1013  IP6_CONFIG_NVDATA                  *Ip6NvData;
     1014  EFI_IP6_CONFIG_PROTOCOL            *Ip6Config;
     1015  EFI_STATUS                         Status;
     1016
     1017  if ((IfrNvData == NULL) || (Instance == NULL)) {
     1018    return EFI_INVALID_PARAMETER;
     1019  }
     1020
     1021  NET_CHECK_SIGNATURE (Instance, IP6_CONFIG_INSTANCE_SIGNATURE);
     1022  Ip6NvData = &Instance->Ip6NvData;
     1023  Ip6Config = &Instance->Ip6Config;
     1024
     1025  //
     1026  // Update those fields which don't have INTERACTIVE attribute.
     1027  //
     1028  if (IfrNvData->Policy == IP6_POLICY_AUTO) {
     1029    Ip6NvData->Policy = Ip6ConfigPolicyAutomatic;
     1030  } else if (IfrNvData->Policy == IP6_POLICY_MANUAL) {
     1031    Ip6NvData->Policy = Ip6ConfigPolicyManual;
     1032  }
     1033
     1034  Ip6NvData->DadTransmitCount.DupAddrDetectTransmits = IfrNvData->DadTransmitCount;
     1035
     1036  //
     1037  // Set the configured policy.
     1038  //
     1039  Status = Ip6Config->SetData (
     1040                        Ip6Config,
     1041                        Ip6ConfigDataTypePolicy,
     1042                        sizeof (EFI_IP6_CONFIG_POLICY),
     1043                        &Ip6NvData->Policy
     1044                        );
     1045  if (EFI_ERROR (Status)) {
     1046    return Status;
     1047  }
     1048
     1049  //
     1050  // Set the duplicate address detection transmits count.
     1051  //
     1052  Status = Ip6Config->SetData (
     1053                        Ip6Config,
     1054                        Ip6ConfigDataTypeDupAddrDetectTransmits,
     1055                        sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS),
     1056                        &Ip6NvData->DadTransmitCount
     1057                        );
     1058  if (EFI_ERROR (Status)) {
     1059    return Status;
     1060  }
     1061
     1062  //
     1063  // Set the alternative interface ID
     1064  //
     1065  Status = Ip6Config->SetData (
     1066                        Ip6Config,
     1067                        Ip6ConfigDataTypeAltInterfaceId,
     1068                        sizeof (EFI_IP6_CONFIG_INTERFACE_ID),
     1069                        &Ip6NvData->InterfaceId
     1070                        );
     1071  if (EFI_ERROR (Status)) {
     1072    return Status;
     1073  }
     1074
     1075  return EFI_SUCCESS;
     1076}
     1077
     1078/**
     1079  Convert IFR data into IP6 configuration data. The policy, configured
     1080  manual address, gateway address, and DNS server address will be saved.
     1081
     1082  @param[in]       IfrNvData       The IFR NV data.
     1083  @param[in, out]  Instance        The IP6 config instance data.
     1084
     1085  @retval EFI_SUCCESS              The operation finished successfully.
     1086  @retval EFI_INVALID_PARAMETER    Any input parameter is invalid.
     1087  @retval Others                   Other errors as indicated.
     1088
     1089**/
     1090EFI_STATUS
     1091Ip6ConvertIfrNvDataToConfigNvDataAdvanced (
    11281092  IN     IP6_CONFIG_IFR_NVDATA       *IfrNvData,
    11291093  IN OUT IP6_CONFIG_INSTANCE         *Instance
     
    11441108  }
    11451109
     1110  if (IfrNvData->Policy == IP6_POLICY_AUTO) {
     1111    return EFI_SUCCESS;
     1112  }
     1113
    11461114  NET_CHECK_SIGNATURE (Instance, IP6_CONFIG_INSTANCE_SIGNATURE);
    11471115  Ip6NvData = &Instance->Ip6NvData;
     
    11511119  // Update those fields which don't have INTERACTIVE attribute.
    11521120  //
    1153   if (IfrNvData->Policy == IP6_POLICY_AUTO) {
    1154     Ip6NvData->Policy = Ip6ConfigPolicyAutomatic;
    1155   } else if (IfrNvData->Policy == IP6_POLICY_MANUAL) {
    1156     Ip6NvData->Policy = Ip6ConfigPolicyManual;
    1157   }
    1158 
    1159   Ip6NvData->DadTransmitCount.DupAddrDetectTransmits = IfrNvData->DadTransmitCount;
     1121  Ip6NvData->Policy = Ip6ConfigPolicyManual;
    11601122
    11611123  //
     
    11701132  if (EFI_ERROR (Status)) {
    11711133    return Status;
    1172   }
    1173 
    1174   //
    1175   // Set the duplicate address detection transmits count.
    1176   //
    1177   Status = Ip6Config->SetData (
    1178                         Ip6Config,
    1179                         Ip6ConfigDataTypeDupAddrDetectTransmits,
    1180                         sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS),
    1181                         &Ip6NvData->DadTransmitCount
    1182                         );
    1183   if (EFI_ERROR (Status)) {
    1184     return Status;
    1185   }
    1186 
    1187   //
    1188   // Set the alternative interface ID
    1189   //
    1190   Status = Ip6Config->SetData (
    1191                         Ip6Config,
    1192                         Ip6ConfigDataTypeAltInterfaceId,
    1193                         sizeof (EFI_IP6_CONFIG_INTERFACE_ID),
    1194                         &Ip6NvData->InterfaceId
    1195                         );
    1196   if (EFI_ERROR (Status)) {
    1197     return Status;
    1198   }
    1199 
    1200 
    1201   if (Ip6NvData->Policy == Ip6ConfigPolicyAutomatic) {
    1202     return EFI_SUCCESS;
    12031134  }
    12041135
     
    13581289  return Status;
    13591290}
     1291
    13601292
    13611293/**
     
    15891521
    15901522/**
     1523  Display host addresses, route table, DNS addresses and gateway addresses in
     1524  "IPv6 Current Setting" page.
     1525
     1526  @param[in]       Instance        The IP6 config instance data.
     1527
     1528  @retval EFI_SUCCESS              The operation finished successfully.
     1529  @retval Others                   Other errors as indicated.
     1530
     1531**/
     1532EFI_STATUS
     1533Ip6GetCurrentSetting (
     1534  IN IP6_CONFIG_INSTANCE        *Instance
     1535  )
     1536{
     1537  EFI_IP6_CONFIG_PROTOCOL       *Ip6Config;
     1538  EFI_HII_HANDLE                HiiHandle;
     1539  EFI_IP6_CONFIG_INTERFACE_INFO *Data;
     1540  UINTN                         DataSize;
     1541  EFI_STATUS                    Status;
     1542  CHAR16                        PortString[ADDRESS_STR_MAX_SIZE];
     1543  EFI_IP6_CONFIG_INTERFACE_INFO *IfInfo;
     1544 
     1545
     1546  Ip6Config = &Instance->Ip6Config;
     1547  HiiHandle = Instance->CallbackInfo.RegisteredHandle;
     1548  Data      = NULL;
     1549
     1550  //
     1551  // Get current interface info.
     1552  //
     1553  Status = Ip6ConfigNvGetData (
     1554             Ip6Config,
     1555             Ip6ConfigDataTypeInterfaceInfo,
     1556             &DataSize,
     1557             (VOID **) &Data
     1558             );
     1559  if (EFI_ERROR (Status)) {
     1560    return Status;
     1561  }
     1562
     1563  //
     1564  // Generate dynamic text opcode for host address and draw it.
     1565  //
     1566  IfInfo = (EFI_IP6_CONFIG_INTERFACE_INFO *) Data;
     1567  Status = Ip6ConvertAddressListToString (
     1568             PortString,
     1569             HiiHandle,
     1570             Ip6ConfigNvHostAddress,
     1571             IfInfo->AddressInfo,
     1572             IfInfo->AddressInfoCount
     1573             );
     1574  if (EFI_ERROR (Status)) {
     1575    FreePool (Data);
     1576    return Status;
     1577  }
     1578
     1579  //
     1580  // Generate the dynamic text opcode for route table and draw it.
     1581  //
     1582  Status = Ip6ConvertAddressListToString (
     1583             PortString,
     1584             HiiHandle,
     1585             Ip6ConfigNvRouteTable,
     1586             IfInfo->RouteTable,
     1587             IfInfo->RouteCount
     1588             );
     1589  if (EFI_ERROR (Status)) {
     1590    FreePool (Data);
     1591    return Status;
     1592  }
     1593
     1594  //
     1595  // Get DNS server list.
     1596  //
     1597  FreePool (Data);
     1598  DataSize = 0;
     1599  Data = NULL;
     1600  Status = Ip6ConfigNvGetData (
     1601             Ip6Config,
     1602             Ip6ConfigDataTypeDnsServer,
     1603             &DataSize,
     1604             (VOID **) &Data
     1605             );
     1606  if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
     1607    if (Data != NULL) {
     1608      FreePool (Data);
     1609    }
     1610    return Status;
     1611  }
     1612
     1613  if (DataSize > 0) {
     1614    //
     1615    // Generate the dynamic text opcode for DNS server and draw it.
     1616    //
     1617    Status = Ip6ConvertAddressListToString (
     1618               PortString,
     1619               HiiHandle,
     1620               Ip6ConfigNvDnsAddress,
     1621               Data,
     1622               DataSize / sizeof (EFI_IPv6_ADDRESS)
     1623               );
     1624    if (EFI_ERROR (Status)) {
     1625      FreePool (Data);
     1626      return Status;
     1627    }
     1628  }
     1629
     1630  //
     1631  // Get gateway adderss list.
     1632  //
     1633  if (Data != NULL) {
     1634    FreePool (Data);
     1635  }
     1636
     1637  DataSize = 0;
     1638  Data = NULL;
     1639  Status = Ip6ConfigNvGetData (
     1640             Ip6Config,
     1641             Ip6ConfigDataTypeGateway,
     1642             &DataSize,
     1643             (VOID **) &Data
     1644             );
     1645  if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
     1646    if (Data != NULL) {
     1647      FreePool (Data);
     1648    }
     1649    return Status;
     1650  }
     1651
     1652  if (DataSize > 0) {
     1653    //
     1654    // Generate the dynamic text opcode for gateway and draw it.
     1655    //
     1656    Status = Ip6ConvertAddressListToString (
     1657               PortString,
     1658               HiiHandle,
     1659               Ip6ConfigNvGatewayAddress,
     1660               Data,
     1661               DataSize / sizeof (EFI_IPv6_ADDRESS)
     1662               );
     1663    if (EFI_ERROR (Status)) {
     1664      FreePool (Data);
     1665      return Status;
     1666    }
     1667  }
     1668
     1669  if (Data != NULL) {
     1670    FreePool (Data);
     1671  }
     1672
     1673  return EFI_SUCCESS;
     1674}
     1675
     1676/**
    15911677  This function is called to provide results data to the driver.
    15921678  This data consists of a unique key that is used to identify
     
    16331719  IP6_CONFIG_INSTANCE           *Instance;
    16341720  IP6_CONFIG_NVDATA             *Ip6NvData;
    1635   EFI_IP6_CONFIG_PROTOCOL       *Ip6Config;
    1636   EFI_IP6_CONFIG_INTERFACE_INFO *Data;
    1637   UINTN                         DataSize;
    1638   CHAR16                        PortString[ADDRESS_STR_MAX_SIZE];
    1639   EFI_HII_HANDLE                HiiHandle;
    1640   EFI_IP6_CONFIG_INTERFACE_INFO *IfInfo;
    16411721
    16421722  if (This == NULL) {
     
    16771757    switch (QuestionId) {
    16781758    case KEY_GET_CURRENT_SETTING:
    1679       Ip6Config = &Instance->Ip6Config;
    1680       HiiHandle = Instance->CallbackInfo.RegisteredHandle;
    1681       Data      = NULL;
    1682 
    1683       //
    1684       // Get current interface info.
    1685       //
    1686       Status = Ip6ConfigNvGetData (
    1687                  Ip6Config,
    1688                  Ip6ConfigDataTypeInterfaceInfo,
    1689                  &DataSize,
    1690                  (VOID **) &Data
    1691                  );
    1692       if (EFI_ERROR (Status)) {
    1693         return Status;
    1694       }
    1695 
    1696       //
    1697       // Generate dynamic text opcode for host address and draw it.
    1698       //
    1699       IfInfo = (EFI_IP6_CONFIG_INTERFACE_INFO *) Data;
    1700       Status = Ip6ConvertAddressListToString (
    1701                  PortString,
    1702                  HiiHandle,
    1703                  Ip6ConfigNvHostAddress,
    1704                  IfInfo->AddressInfo,
    1705                  IfInfo->AddressInfoCount
    1706                  );
    1707       if (EFI_ERROR (Status)) {
    1708         FreePool (Data);
    1709         return Status;
    1710       }
    1711 
    1712       //
    1713       // Generate the dynamic text opcode for route table and draw it.
    1714       //
    1715       Status = Ip6ConvertAddressListToString (
    1716                  PortString,
    1717                  HiiHandle,
    1718                  Ip6ConfigNvRouteTable,
    1719                  IfInfo->RouteTable,
    1720                  IfInfo->RouteCount
    1721                  );
    1722       if (EFI_ERROR (Status)) {
    1723         FreePool (Data);
    1724         return Status;
    1725       }
    1726 
    1727       //
    1728       // Get DNS server list.
    1729       //
    1730       FreePool (Data);
    1731       DataSize = 0;
    1732       Data = NULL;
    1733       Status = Ip6ConfigNvGetData (
    1734                  Ip6Config,
    1735                  Ip6ConfigDataTypeDnsServer,
    1736                  &DataSize,
    1737                  (VOID **) &Data
    1738                  );
    1739       if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
    1740         if (Data != NULL) {
    1741           FreePool (Data);
    1742         }
    1743         return Status;
    1744       }
    1745 
    1746       if (DataSize > 0) {
    1747         //
    1748         // Generate the dynamic text opcode for DNS server and draw it.
    1749         //
    1750         Status = Ip6ConvertAddressListToString (
    1751                    PortString,
    1752                    HiiHandle,
    1753                    Ip6ConfigNvDnsAddress,
    1754                    Data,
    1755                    DataSize / sizeof (EFI_IPv6_ADDRESS)
    1756                    );
    1757         if (EFI_ERROR (Status)) {
    1758           FreePool (Data);
    1759           return Status;
    1760         }
    1761       }
    1762 
    1763       //
    1764       // Get gateway adderss list.
    1765       //
    1766       if (Data != NULL) {
    1767         FreePool (Data);
    1768       }
    1769 
    1770       DataSize = 0;
    1771       Data = NULL;
    1772       Status = Ip6ConfigNvGetData (
    1773                  Ip6Config,
    1774                  Ip6ConfigDataTypeGateway,
    1775                  &DataSize,
    1776                  (VOID **) &Data
    1777                  );
    1778       if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
    1779         if (Data != NULL) {
    1780           FreePool (Data);
    1781         }
    1782         return Status;
    1783       }
    1784 
    1785       if (DataSize > 0) {
    1786         //
    1787         // Generate the dynamic text opcode for gateway and draw it.
    1788         //
    1789         Status = Ip6ConvertAddressListToString (
    1790                    PortString,
    1791                    HiiHandle,
    1792                    Ip6ConfigNvGatewayAddress,
    1793                    Data,
    1794                    DataSize / sizeof (EFI_IPv6_ADDRESS)
    1795                    );
    1796         if (EFI_ERROR (Status)) {
    1797           FreePool (Data);
    1798           return Status;
    1799         }
    1800       }
    1801 
    1802       if (Data != NULL) {
    1803         FreePool (Data);
    1804       }
    1805 
    1806       Status = EFI_SUCCESS;
    1807 
     1759      Status = Ip6GetCurrentSetting (Instance);
    18081760      break;
    18091761
     
    18141766    switch (QuestionId) {
    18151767    case KEY_SAVE_CONFIG_CHANGES:
     1768      Status = Ip6ConvertIfrNvDataToConfigNvDataAdvanced (IfrNvData, Instance);
     1769      if (EFI_ERROR (Status)) {
     1770        break;
     1771      }
     1772
     1773      Status = Ip6GetCurrentSetting (Instance);
     1774
    18161775      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;
    18171776      break;
     
    18301789
    18311790    case KEY_SAVE_CHANGES:
    1832       Status = Ip6ConvertIfrNvDataToConfigNvData (IfrNvData, Instance);
     1791      Status = Ip6ConvertIfrNvDataToConfigNvDataGeneral (IfrNvData, Instance);
    18331792      if (EFI_ERROR (Status)) {
    18341793        break;
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Ip6Dxe/Ip6Driver.c

    r48674 r58459  
    22  The driver binding and service binding protocol for IP6 driver.
    33
    4   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    9595  the resource allocated by the instance. The instance may be
    9696  partly initialized, or partly destroyed. If a resource is
    97   destroyed, it is marked as that in case the destory failed and
     97  destroyed, it is marked as that in case the destroy failed and
    9898  being called again later.
    9999
     
    115115  Ip6ConfigCleanInstance (&IpSb->Ip6ConfigInstance);
    116116
    117   //
    118   // Leave link-scope all-nodes multicast address (FF02::1)
    119   //
    120   Ip6SetToAllNodeMulticast (FALSE, IP6_LINK_LOCAL_SCOPE, &AllNodes);
    121 
    122   Status = Ip6LeaveGroup (IpSb, &AllNodes);
    123   if (EFI_ERROR (Status)) {
    124     return Status;
     117  if (!IpSb->LinkLocalDadFail) {
     118    //
     119    // Leave link-scope all-nodes multicast address (FF02::1)
     120    //
     121    Ip6SetToAllNodeMulticast (FALSE, IP6_LINK_LOCAL_SCOPE, &AllNodes);
     122
     123    Status = Ip6LeaveGroup (IpSb, &AllNodes);
     124    if (EFI_ERROR (Status)) {
     125      return Status;
     126    } 
    125127  }
    126128
     
    245247  IpSb->ServiceBinding.DestroyChild = Ip6ServiceBindingDestroyChild;
    246248  IpSb->State                       = IP6_SERVICE_UNSTARTED;
    247   IpSb->InDestroy                   = FALSE;
    248249
    249250  IpSb->NumChildren                 = 0;
     
    412413  }
    413414
    414   //
    415   // The timer expires every 100 (IP6_TIMER_INTERVAL_IN_MS) milliseconds.
    416   //
    417   Status = gBS->SetTimer (IpSb->FasterTimer, TimerPeriodic, TICKS_PER_MS * IP6_TIMER_INTERVAL_IN_MS);
    418   if (EFI_ERROR (Status)) {
    419     goto ON_ERROR;
    420   }
    421 
    422   //
    423   // The timer expires every 1000 (IP6_ONE_SECOND_IN_MS) milliseconds.
    424   //
    425   Status = gBS->SetTimer (IpSb->Timer, TimerPeriodic, TICKS_PER_MS * IP6_ONE_SECOND_IN_MS);
    426   if (EFI_ERROR (Status)) {
    427     goto ON_ERROR;
    428   }
    429 
     415  Status = NetLibGetMacString (IpSb->Controller, IpSb->Image, &IpSb->MacString);
     416  if (EFI_ERROR (Status)) {
     417    goto ON_ERROR;
     418  }
     419
     420  Status = Ip6ConfigInitInstance (&IpSb->Ip6ConfigInstance);
     421  if (EFI_ERROR (Status)) {
     422    goto ON_ERROR;
     423  }
     424
     425  IpSb->DefaultInterface = Ip6CreateInterface (IpSb, TRUE);
     426  if (IpSb->DefaultInterface == NULL) {
     427    Status = EFI_DEVICE_ERROR;
     428    goto ON_ERROR;
     429  }
    430430
    431431  Status = gBS->CreateEvent (
     
    440440  }
    441441
    442   Status = Ip6ReceiveFrame (Ip6AcceptFrame, IpSb);
    443   if (EFI_ERROR (Status)) {
    444     goto ON_ERROR;
    445   }
    446 
    447   Status = NetLibGetMacString (IpSb->Controller, IpSb->Image, &IpSb->MacString);
    448   if (EFI_ERROR (Status)) {
    449     goto ON_ERROR;
    450   }
    451 
    452   Status = Ip6ConfigInitInstance (&IpSb->Ip6ConfigInstance);
    453   if (EFI_ERROR (Status)) {
    454     goto ON_ERROR;
    455   }
    456 
    457   IpSb->DefaultInterface = Ip6CreateInterface (IpSb, TRUE);
    458   if (IpSb->DefaultInterface == NULL) {
    459     Status = EFI_DEVICE_ERROR;
    460     goto ON_ERROR;
    461   }
    462 
    463442  //
    464443  // If there is any manual address, set it.
    465444  //
    466445  DataItem = &IpSb->Ip6ConfigInstance.DataItem[Ip6ConfigDataTypeManualAddress];
     446  if (DataItem->Data.Ptr != NULL) {
     447    DataItem->SetData (
     448                &IpSb->Ip6ConfigInstance,
     449                DataItem->DataSize,
     450                DataItem->Data.Ptr
     451                );
     452  }
     453
     454  //
     455  // If there is any gateway address, set it.
     456  //
     457  DataItem = &IpSb->Ip6ConfigInstance.DataItem[Ip6ConfigDataTypeGateway];
    467458  if (DataItem->Data.Ptr != NULL) {
    468459    DataItem->SetData (
     
    545536                  );
    546537
    547   if (EFI_ERROR (Status)) {
    548 
    549     Ip6CleanService (IpSb);
    550     FreePool (IpSb);
    551   } else {
     538  if (!EFI_ERROR (Status)) {
     539    //
     540    // ready to go: start the receiving and timer
     541    //
     542    Status = Ip6ReceiveFrame (Ip6AcceptFrame, IpSb);
     543    if (EFI_ERROR (Status)) {
     544      goto ON_ERROR;
     545    }
     546
     547    //
     548    // The timer expires every 100 (IP6_TIMER_INTERVAL_IN_MS) milliseconds.
     549    //
     550    Status = gBS->SetTimer (
     551                    IpSb->FasterTimer,
     552                    TimerPeriodic,
     553                    TICKS_PER_MS * IP6_TIMER_INTERVAL_IN_MS
     554                    );
     555    if (EFI_ERROR (Status)) {
     556      goto ON_ERROR;
     557    }
     558
     559    //
     560    // The timer expires every 1000 (IP6_ONE_SECOND_IN_MS) milliseconds.
     561    //
     562    Status = gBS->SetTimer (
     563                    IpSb->Timer,
     564                    TimerPeriodic,
     565                    TICKS_PER_MS * IP6_ONE_SECOND_IN_MS
     566                    );
     567    if (EFI_ERROR (Status)) {
     568      goto ON_ERROR;
     569    }   
     570
    552571    //
    553572    // Initialize the IP6 ID
     
    555574    mIp6Id = NET_RANDOM (NetRandomInitSeed ());
    556575
    557     Ip6SetVariableData (IpSb);
    558   }
    559 
     576    return EFI_SUCCESS;
     577  }
     578
     579ON_ERROR:
     580  Ip6CleanService (IpSb);
     581  FreePool (IpSb);
    560582  return Status;
     583}
     584
     585/**
     586  Callback function which provided by user to remove one node in NetDestroyLinkList process.
     587 
     588  @param[in]    Entry           The entry to be removed.
     589  @param[in]    Context         Pointer to the callback context corresponds to the Context in NetDestroyLinkList.
     590
     591  @retval EFI_SUCCESS           The entry has been removed successfully.
     592  @retval Others                Fail to remove the entry.
     593
     594**/
     595EFI_STATUS
     596EFIAPI
     597Ip6DestroyChildEntryInHandleBuffer (
     598  IN LIST_ENTRY         *Entry,
     599  IN VOID               *Context
     600  )
     601{
     602  IP6_PROTOCOL                  *IpInstance;
     603  EFI_SERVICE_BINDING_PROTOCOL  *ServiceBinding;
     604  UINTN                         NumberOfChildren;
     605  EFI_HANDLE                    *ChildHandleBuffer;
     606
     607  if (Entry == NULL || Context == NULL) {
     608    return EFI_INVALID_PARAMETER;
     609  }
     610
     611  IpInstance = NET_LIST_USER_STRUCT_S (Entry, IP6_PROTOCOL, Link, IP6_PROTOCOL_SIGNATURE);
     612  ServiceBinding    = ((IP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding;
     613  NumberOfChildren  = ((IP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren;
     614  ChildHandleBuffer = ((IP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer;
     615
     616  if (!NetIsInHandleBuffer (IpInstance->Handle, NumberOfChildren, ChildHandleBuffer)) {
     617    return EFI_SUCCESS;
     618  }
     619
     620  return ServiceBinding->DestroyChild (ServiceBinding, IpInstance->Handle);
    561621}
    562622
     
    584644  )
    585645{
    586   EFI_SERVICE_BINDING_PROTOCOL  *ServiceBinding;
    587   IP6_SERVICE                   *IpSb;
    588   IP6_PROTOCOL                  *IpInstance;
    589   EFI_HANDLE                    NicHandle;
    590   EFI_STATUS                    Status;
    591   BOOLEAN                       IsDhcp6;
    592   EFI_TPL                       OldTpl;
    593   INTN                          State;
     646  EFI_SERVICE_BINDING_PROTOCOL            *ServiceBinding;
     647  IP6_SERVICE                             *IpSb;
     648  EFI_HANDLE                              NicHandle;
     649  EFI_STATUS                              Status;
     650  LIST_ENTRY                              *List;
     651  INTN                                    State;
     652  BOOLEAN                                 IsDhcp6;
     653  IP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context;
    594654
    595655  IsDhcp6   = FALSE;
    596   NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiDhcp6ProtocolGuid);
    597 
    598   if (NicHandle != NULL) {
    599     //
    600     // DriverBindingStop is triggered by the uninstallation of the EFI DHCPv6
    601     // Protocol used by Ip6Config.
    602     //
    603     IsDhcp6 = TRUE;
    604   } else {
    605 
    606     NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiManagedNetworkProtocolGuid);
    607 
    608     if (NicHandle == NULL) {
    609       return EFI_DEVICE_ERROR;
     656  NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiManagedNetworkProtocolGuid);
     657  if (NicHandle == NULL) {
     658    NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiDhcp6ProtocolGuid);
     659    if (NicHandle != NULL) {
     660      IsDhcp6 = TRUE;
     661    } else {
     662      return EFI_SUCCESS;
    610663    }
    611664  }
     
    625678  IpSb = IP6_SERVICE_FROM_PROTOCOL (ServiceBinding);
    626679
    627   OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
    628 
    629   if (IpSb->InDestroy) {
    630     Status = EFI_SUCCESS;
    631     goto Exit;
    632   }
    633 
    634680  if (IsDhcp6) {
    635 
    636681    Status = Ip6ConfigDestroyDhcp6 (&IpSb->Ip6ConfigInstance);
    637682    gBS->CloseEvent (IpSb->Ip6ConfigInstance.Dhcp6Event);
    638683    IpSb->Ip6ConfigInstance.Dhcp6Event = NULL;
    639   } else if (NumberOfChildren == 0) {
    640 
    641     IpSb->InDestroy = TRUE;
     684  } else if (NumberOfChildren != 0) {
     685    //
     686    // NumberOfChildren is not zero, destroy the IP6 children instances in ChildHandleBuffer.
     687    //
     688    List = &IpSb->Children;
     689    Context.ServiceBinding    = ServiceBinding;
     690    Context.NumberOfChildren  = NumberOfChildren;
     691    Context.ChildHandleBuffer = ChildHandleBuffer;
     692    Status = NetDestroyLinkList (
     693               List,
     694               Ip6DestroyChildEntryInHandleBuffer,
     695               &Context,
     696               NULL
     697               );
     698  } else if (IsListEmpty (&IpSb->Children)) {
    642699    State           = IpSb->State;
    643700    IpSb->State     = IP6_SERVICE_DESTROY;
    644 
    645     //
    646     // Clear the variable data.
    647     //
    648     Ip6ClearVariableData (IpSb);
    649701
    650702    Status = Ip6CleanService (IpSb);
     
    664716    ASSERT_EFI_ERROR (Status);
    665717    FreePool (IpSb);
    666   } else {
    667     //
    668     // NumberOfChildren is not zero, destroy all IP6 children instances.
    669     //
    670     while (!IsListEmpty (&IpSb->Children)) {
    671       IpInstance = NET_LIST_HEAD (&IpSb->Children, IP6_PROTOCOL, Link);
    672       ServiceBinding->DestroyChild (ServiceBinding, IpInstance->Handle);
    673     }
    674 
    675     if (IpSb->NumChildren != 0) {
    676       Status = EFI_DEVICE_ERROR;
    677     }
    678   }
    679 
     718    Status = EFI_SUCCESS;
     719  }
     720 
    680721Exit:
    681 
    682   gBS->RestoreTPL (OldTpl);
    683 
    684722  return Status;
    685723}
     
    819857  EFI_IP6_PROTOCOL          *Ip6;
    820858  EFI_TPL                   OldTpl;
    821   INTN                      State;
    822859
    823860  if ((This == NULL) || (ChildHandle == NULL)) {
     
    853890  //
    854891  // A child can be destroyed more than once. For example,
    855   // Ip6DriverBindingStop will destory all of its children.
    856   // when UDP driver is being stopped, it will destory all
     892  // Ip6DriverBindingStop will destroy all of its children.
     893  // when UDP driver is being stopped, it will destroy all
    857894  // the IP child it opens.
    858895  //
    859   if (IpInstance->State == IP6_STATE_DESTROY) {
     896  if (IpInstance->InDestroy) {
    860897    gBS->RestoreTPL (OldTpl);
    861898    return EFI_SUCCESS;
    862899  }
    863900
    864   State             = IpInstance->State;
    865   IpInstance->State = IP6_STATE_DESTROY;
     901  IpInstance->InDestroy = TRUE;
    866902
    867903  //
     
    889925  // that means there is a resource leak.
    890926  //
     927  gBS->RestoreTPL (OldTpl);
    891928  Status = gBS->UninstallProtocolInterface (
    892929                  ChildHandle,
     
    894931                  &IpInstance->Ip6Proto
    895932                  );
    896 
     933  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
    897934  if (EFI_ERROR (Status)) {
    898935    goto ON_ERROR;
     
    900937
    901938  Status = Ip6CleanProtocol (IpInstance);
    902 
    903   Ip6SetVariableData (IpSb);
    904 
    905939  if (EFI_ERROR (Status)) {
    906940    gBS->InstallMultipleProtocolInterfaces (
     
    924958
    925959ON_ERROR:
    926   IpInstance->State = State;
    927960  gBS->RestoreTPL (OldTpl);
    928961
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Ip6Dxe/Ip6Driver.h

    r48674 r58459  
    22  The driver binding and service binding protocol for IP6 driver.
    33
    4   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    2020extern EFI_COMPONENT_NAME_PROTOCOL  gIp6ComponentName;
    2121extern EFI_COMPONENT_NAME2_PROTOCOL gIp6ComponentName2;
     22extern EFI_UNICODE_STRING_TABLE     *gIp6ControllerNameTable;
     23
     24typedef struct {
     25  EFI_SERVICE_BINDING_PROTOCOL  *ServiceBinding;
     26  UINTN                         NumberOfChildren;
     27  EFI_HANDLE                    *ChildHandleBuffer;
     28}IP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT;
    2229
    2330/**
     
    2532  the resource allocated by the instance. The instance may be
    2633  partly initialized, or partly destroyed. If a resource is
    27   destroyed, it is marked as that in case the destory failed and
     34  destroyed, it is marked as that in case the destroy failed and
    2835  being called again later.
    2936
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Ip6Dxe/Ip6Dxe.inf

    r48674 r58459  
    11## @file
    2 #  Component description file for Ip6 module.
     2#  Basic IPv6 packet I/O Service.
     3#   
     4#  This module provides basic network IPv6 packet I/O services which includes support for
     5#  Neighbor Discovery Protocol (ND), Multicast Listener Discovery Protocol (MLD),
     6#  and a subset of the Internet Control Message Protocol (ICMPv6). This driver
     7#  also provides the mechanism to set and get various types of configurations for
     8#  the EFI IPv6 network stack.
    39#
    4 #  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     10#  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    511#
    612#  This program and the accompanying materials
     
    2228  ENTRY_POINT                    = Ip6DriverEntryPoint
    2329  UNLOAD_IMAGE                   = NetLibDefaultUnload
     30  MODULE_UNI_FILE                = Ip6Dxe.uni
    2431
    2532#
     
    8794
    8895[Protocols]
    89   gEfiManagedNetworkServiceBindingProtocolGuid
    90   gEfiManagedNetworkProtocolGuid
    91   gEfiIp6ServiceBindingProtocolGuid
    92   gEfiIp6ProtocolGuid
    93   gEfiIp6ConfigProtocolGuid
    94   gEfiDhcp6ServiceBindingProtocolGuid
    95   gEfiDhcp6ProtocolGuid
    96   gEfiIpSec2ProtocolGuid
    97   gEfiHiiConfigAccessProtocolGuid
     96  gEfiManagedNetworkServiceBindingProtocolGuid     ## TO_START
     97  gEfiManagedNetworkProtocolGuid                   ## TO_START
     98  gEfiIp6ServiceBindingProtocolGuid                ## BY_START
     99  gEfiIp6ProtocolGuid                              ## BY_START
     100  gEfiIp6ConfigProtocolGuid                        ## BY_START
     101  gEfiDhcp6ServiceBindingProtocolGuid              ## SOMETIMES_CONSUMES
     102  gEfiDhcp6ProtocolGuid                            ## SOMETIMES_CONSUMES
     103  gEfiIpSec2ProtocolGuid                           ## SOMETIMES_CONSUMES
     104  gEfiHiiConfigAccessProtocolGuid                  ## SOMETIMES_CONSUMES
    98105
    99106[Guids]
    100   gEfiIfrTianoGuid                              ## CONSUMES ## GUID
    101   gIp6ConfigNvDataGuid                          ## PRODUCES ## GUID
     107  ## SOMETIMES_CONSUMES ## HII
     108  gEfiIfrTianoGuid
     109  ## SOMETIMES_CONSUMES ## UNDEFINED # HiiIsConfigHdrMatch   mIp6ConfigStorageName
     110  ## SOMETIMES_PRODUCES ## UNDEFINED # HiiConstructConfigHdr mIp6ConfigStorageName
     111  ## SOMETIMES_PRODUCES ## UNDEFINED # HiiAddPackages        Ip6DxeStrings Ip6ConfigBin
     112  ## SOMETIMES_CONSUMES ## UNDEFINED # HiiUpdateForm
     113  ## SOMETIMES_CONSUMES ## HII
     114  gIp6ConfigNvDataGuid
     115[UserExtensions.TianoCore."ExtraFiles"]
     116  Ip6DxeExtra.uni
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Ip6Dxe/Ip6If.c

    r48674 r58459  
    22  Implement IP6 pesudo interface.
    33
    4   Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    315315
    316316  //
    317   // Destory the interface if this is the last IP instance.
     317  // Destroy the interface if this is the last IP instance.
    318318  // Remove all the system transmitted packets
    319319  // from this interface, cancel the receive request if exists.
     
    566566  EFI_STATUS                Status;
    567567  IP6_LINK_RX_TOKEN         *Token;
    568 
    569   if (IpSb->InDestroy) {
    570     return EFI_INVALID_PARAMETER;
    571   }
    572 
     568 
    573569  NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
    574570
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Ip6Dxe/Ip6Impl.c

    r48674 r58459  
    22  Implementation of EFI_IP6_PROTOCOL protocol interfaces.
    33
    4   Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    636636  IpSb       = IpInstance->Service;
    637637
    638   if (IpSb->LinkLocalDadFail) {
     638  if (IpSb->LinkLocalDadFail && Ip6ConfigData != NULL) {
    639639    return EFI_DEVICE_ERROR;
    640640  }
     
    690690
    691691    //
    692     // Don't change the state if it is DESTORY, consider the following
     692    // Don't change the state if it is DESTROY, consider the following
    693693    // valid sequence: Mnp is unloaded-->Ip Stopped-->Udp Stopped,
    694694    // Configure (ThisIp, NULL). If the state is changed to UNCONFIGED,
     
    705705  //
    706706  Ip6ServiceConfigMnp (IpInstance->Service, FALSE);
    707 
    708   //
    709   // Update the variable data.
    710   //
    711   Ip6SetVariableData (IpInstance->Service);
    712707
    713708Exit:
     
    17781773  IpSb       = IpInstance->Service;
    17791774
    1780   if (IpSb->LinkLocalDadFail) {
    1781     return EFI_DEVICE_ERROR;
    1782   }
    1783 
    17841775  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
    17851776
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Ip6Dxe/Ip6Impl.h

    r48674 r58459  
    22  Implementation of EFI_IP6_PROTOCOL protocol interfaces and type definitions.
    33
    4   Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    6969#define IP6_STATE_UNCONFIGED   0
    7070#define IP6_STATE_CONFIGED     1
    71 #define IP6_STATE_DESTROY      2
    7271
    7372//
     
    158157
    159158  EFI_IP6_CONFIG_DATA       ConfigData;
     159  BOOLEAN                   InDestroy;
    160160};
    161161
     
    164164  EFI_SERVICE_BINDING_PROTOCOL    ServiceBinding;
    165165  INTN                            State;
    166   BOOLEAN                         InDestroy;
    167166
    168167  //
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Ip6Dxe/Ip6Input.c

    r48674 r58459  
    22  IP6 internal functions to process the incoming packets.
    33
    4   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    244244  // overlaps, trim the overlapped part off THIS fragment.
    245245  //
    246   if ((Cur != ListHead) && ((Prev = Cur->BackLink) != ListHead)) {
     246  if ((Prev = Cur->BackLink) != ListHead) {
    247247    Fragment  = NET_LIST_USER_STRUCT (Prev, NET_BUF, List);
    248248    Node      = IP6_GET_CLIP_INFO (Fragment);
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Ip6Dxe/Ip6Nd.c

    r48674 r58459  
    22  Implementation of Neighbor Discovery support routines.
    33
    4   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    262262
    263263/**
    264   Destory a IP6 prefix list entry.
     264  Destroy a IP6 prefix list entry.
    265265
    266266  @param[in]  IpSb              The pointer to IP6_SERVICE instance.
     
    822822  EFI_DHCP6_PACKET_OPTION   *Oro;
    823823  EFI_DHCP6_RETRANSMISSION  InfoReqReXmit;
    824 
     824  EFI_IPv6_ADDRESS          AllNodes;
     825 
    825826  IpSb     = IpIf->Service;
    826827  AddrInfo = DadEntry->AddressInfo;
     
    922923    RemoveEntryList (&DadEntry->Link);
    923924    FreePool (DadEntry);
     925    //
     926    // Leave link-scope all-nodes multicast address (FF02::1)
     927    //
     928    Ip6SetToAllNodeMulticast (FALSE, IP6_LINK_LOCAL_SCOPE, &AllNodes);
     929    Ip6LeaveGroup (IpSb, &AllNodes);
    924930    //
    925931    // Disable IP operation since link-local address is a duplicate address.
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Ip6Dxe/Ip6Nd.h

    r48674 r58459  
    22  Definition of Neighbor Discovery support routines.
    33
    4   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    337337
    338338/**
    339   Destory a IP6 prefix list entry.
     339  Destroy a IP6 prefix list entry.
    340340
    341341  @param[in]  IpSb              The pointer to IP6_SERVICE instance.
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Ip6Dxe/Ip6NvData.h

    r48674 r58459  
    22  NVData structure used by the IP6 configuration component.
    33
    4   Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    4444#define INTERFACE_ID_STR_MIN_SIZE 1
    4545#define INTERFACE_ID_STR_MAX_SIZE 23
    46 #define INTERFACE_ID_STR_STORAGE  24
     46#define INTERFACE_ID_STR_STORAGE  25
    4747#define IP6_STR_MAX_SIZE          40
    4848#define ADDRESS_STR_MIN_SIZE      2
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Ip6Dxe/Ip6Output.c

    r48674 r58459  
    22  The internal functions and routines to transmit the IP6 packet.
    33
    4   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    388388  EFI_STATUS                Status;
    389389  UINT8                     NextHeader;
     390
     391  UpdatedExtHdrs = NULL;
    390392
    391393  //
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/IpSecDxe/ComponentName.c

    r48674 r58459  
    22  UEFI Component Name(2) protocol implementation for IPsec driver.
    33
    4   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    166166    "eng;en",
    167167    L"IpSec Driver"
     168  },
     169  {
     170    NULL,
     171    NULL
     172  }
     173};
     174
     175GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIpSecControllerNameTable[] = {
     176  {
     177    "eng;en",
     178    L"IPsec Controller"
    168179  },
    169180  {
     
    307318  )
    308319{
    309   return EFI_UNSUPPORTED;
     320  EFI_STATUS Status;
     321
     322  //
     323  // ChildHandle must be NULL for a Device Driver
     324  //
     325  if (ChildHandle != NULL) {
     326    return EFI_UNSUPPORTED;
     327  }
     328 
     329  //
     330  // Make sure this driver is currently managing ControllerHandle
     331  //
     332  Status = gBS->OpenProtocol (
     333                  ControllerHandle,
     334                  &gEfiIpSec2ProtocolGuid,
     335                  NULL,
     336                  NULL,
     337                  NULL,
     338                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
     339                  );
     340  if (EFI_ERROR (Status)) {
     341    return Status;
     342  }
     343
     344  return LookupUnicodeString2 (
     345           Language,
     346           This->SupportedLanguages,
     347           mIpSecControllerNameTable,
     348           ControllerName,
     349           (BOOLEAN) (This == &gIpSecComponentName)
     350           );
    310351}
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/IpSecDxe/IkeCommon.c

    r48674 r58459  
    22  Common operation of the IKE
    33 
    4   Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    2323//
    2424UINT32            mNextSpi  = IKE_SPI_BASE;
    25 EFI_GUID          mZeroGuid = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
     25EFI_GUID          mZeroGuid = { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } };
    2626
    2727/**
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/IpSecDxe/IkeService.c

    r48674 r58459  
    22  Provide IPsec Key Exchange (IKE) service general interfaces.
    33
    4   Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    3737  1000000,
    3838  FALSE,
    39   {0,0,0,0},
    40   {0,0,0,0},
     39  {{0,0,0,0}},
     40  {{0,0,0,0}},
    4141  IKE_DEFAULT_PORT,
    42   {0,0,0,0},
     42  {{0,0,0,0}},
    4343  0
    4444};
     
    5656  1000000,
    5757  //Access Point
    58   {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
     58  {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}},
    5959  IKE_DEFAULT_PORT,
    60   {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
     60  {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}},
    6161  0
    6262};
     
    347347  @param[in] Private        Point to IPSEC_PRIVATE_DATA
    348348  @param[in] Controller     Handler for NIC card.
     349  @param[in] ImageHandle    The handle that contains the EFI_DRIVER_BINDING_PROTOCOL instance.
    349350
    350351  @retval EFI_SUCCESS             The Operation is successful.
     
    355356IkeOpenInputUdp4 (
    356357  IN IPSEC_PRIVATE_DATA           *Private,
    357   IN EFI_HANDLE                   Controller
     358  IN EFI_HANDLE                   Controller,
     359  IN EFI_HANDLE                   ImageHandle
    358360  )
    359361{
     
    379381  Udp4Srv->Input = UdpIoCreateIo (
    380382                     Controller,
    381                      Private->ImageHandle,
     383                     ImageHandle,
    382384                     IkeConfigUdp4,
    383385                     UDP_IO_UDP4_VERSION,
     
    391393
    392394  Udp4Srv->NicHandle    = Controller;
    393   Udp4Srv->ImageHandle  = Private->ImageHandle;
     395  Udp4Srv->ImageHandle  = ImageHandle;
    394396  Udp4Srv->ListHead     = &(Private->Udp4List);
    395397  Udp4Srv->IpVersion    = UDP_IO_UDP4_VERSION;
     
    418420  @param[in] Private        Point to IPSEC_PRIVATE_DATA
    419421  @param[in] Controller     Handler for NIC card.
     422  @param[in] ImageHandle    The handle that contains the EFI_DRIVER_BINDING_PROTOCOL instance.
    420423
    421424  @retval EFI_SUCCESS             The Operation is successful.
     
    426429IkeOpenInputUdp6 (
    427430  IN IPSEC_PRIVATE_DATA           *Private,
    428   IN EFI_HANDLE                   Controller
     431  IN EFI_HANDLE                   Controller,
     432  IN EFI_HANDLE                   ImageHandle
    429433  )
    430434{
     
    447451  Udp6Srv->Input = UdpIoCreateIo (
    448452                     Controller,
    449                      Private->ImageHandle,
     453                     ImageHandle,
    450454                     IkeConfigUdp6,
    451455                     UDP_IO_UDP6_VERSION,
     
    459463
    460464  Udp6Srv->NicHandle    = Controller;
    461   Udp6Srv->ImageHandle  = Private->ImageHandle;
     465  Udp6Srv->ImageHandle  = ImageHandle;
    462466  Udp6Srv->ListHead     = &(Private->Udp6List);
    463467  Udp6Srv->IpVersion    = UDP_IO_UDP6_VERSION;
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/IpSecDxe/IkeService.h

    r48674 r58459  
    22  Prototypes definitions of IKE service.
    33
    4   Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    144144  @param[in] Private        Point to IPSEC_PRIVATE_DATA
    145145  @param[in] Controller     Handler for NIC card.
     146  @param[in] ImageHandle    The handle that contains the EFI_DRIVER_BINDING_PROTOCOL instance.
    146147
    147148  @retval EFI_SUCCESS             The Operation is successful.
     
    152153IkeOpenInputUdp4 (
    153154  IN IPSEC_PRIVATE_DATA             *Private,
    154   IN EFI_HANDLE                     Controller
     155  IN EFI_HANDLE                     Controller,
     156  IN EFI_HANDLE                     ImageHandle
    155157  );
    156158
     
    163165  @param[in] Private        Point to IPSEC_PRIVATE_DATA
    164166  @param[in] Controller     Handler for NIC card.
     167  @param[in] ImageHandle    The handle that contains the EFI_DRIVER_BINDING_PROTOCOL instance.
    165168
    166169  @retval EFI_SUCCESS             The Operation is successful.
     
    171174IkeOpenInputUdp6 (
    172175  IN IPSEC_PRIVATE_DATA             *Private,
    173   IN EFI_HANDLE                     Controller
     176  IN EFI_HANDLE                     Controller,
     177  IN EFI_HANDLE                     ImageHandle
    174178  );
    175179
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/IpSecDxe/Ikev2/Exchange.c

    r48674 r58459  
    22  The general interfaces of the IKEv2.
    33
    4   Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    468468  // Validate the IKE packet header.
    469469  //
    470   Status = Ikev2ValidateHeader (IkeSaSession, IkePacket->Header);
    471   if (EFI_ERROR (Status)) {
     470  if (!Ikev2ValidateHeader (IkeSaSession, IkePacket->Header)) {
    472471    //
    473472    // Drop the packet if invalid IKE header.
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/IpSecDxe/Ikev2/Payload.c

    r48674 r58459  
    22  The implementation of Payloads Creation.
    33
    4   Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    13941394  CopyMem (
    13951395    IkeSaSession->NCookie,
    1396     NotifyPayload + sizeof (IKEV2_NOTIFY),
     1396    (UINT8 *)NotifyPayload + sizeof (IKEV2_NOTIFY),
    13971397    NotifyDataSize
    13981398    );
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/IpSecDxe/Ikev2/Utility.c

    r48674 r58459  
    22  The Common operations used by IKE Exchange Process.
    33
    4   Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    929929
    930930      Selector = AllocateZeroPool (SelectorSize);
     931      ASSERT (Selector != NULL);
    931932      Status   = EfiIpSecConfigGetNextSelector (
    932933                   &Private->IpSecConfig,
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/IpSecDxe/IpSecCryptIo.c

    r48674 r58459  
    22  Common interfaces to call Security library.
    33
    4   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    827827   
    828828  SigSize   = 0;
     829  RsaContext = NULL;
     830
    829831  //
    830832  // Retrieve RSA Private Key from password-protected PEM data
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/IpSecDxe/IpSecDebug.c

    r48674 r58459  
    2020// The print title for IKEv1 variety phase.
    2121//
    22 CHAR8 *mIkev1StateStr[] = {
     22CHAR8 *mIkev1StateStr[IKE_STATE_NUM] = {
    2323  "IKEv1_MAIN_1",
    2424  "IKEv1_MAIN_2",
     
    3333// The print title for IKEv2 variety phase.
    3434//
    35 CHAR8 *mIkev2StateStr[] = {
     35CHAR8 *mIkev2StateStr[IKE_STATE_NUM] = {
    3636  "IKEv2_STATE_INIT",
    3737  "IKEv2_STATE_AUTH",
     
    167167  )
    168168{
     169  if (Previous >= IKE_STATE_NUM || Current >= IKE_STATE_NUM) {
     170    return;
     171  }
    169172 
    170173  if (Previous == Current) {
     
    173176    } else if (IkeVersion == 2) {
    174177      DEBUG ((DEBUG_INFO, "\n****Current state is %a\n", mIkev2StateStr[Previous]));
    175     }
    176    
     178    }   
    177179  } else {
    178180    if (IkeVersion == 1) {
     
    180182    } else {
    181183      DEBUG ((DEBUG_INFO, "\n****Change state from %a to %a\n", mIkev2StateStr[Previous], mIkev2StateStr[Current]));
    182     }
    183    
    184   }
    185 
     184    }   
     185  }
    186186}
    187187
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/IpSecDxe/IpSecDebug.h

    r48674 r58459  
    2828
    2929#define IPSEC_DEBUG_BYTE_PER_LINE                       8
     30#define IKE_STATE_NUM                                   7
     31
    3032
    3133
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/IpSecDxe/IpSecDriver.c

    r48674 r58459  
    22  Driver Binding Protocol for IPsec Driver.
    33
    4   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    2121
    2222/**
    23   Test to see if this driver supports ControllerHandle.
     23  Test to see if this driver supports ControllerHandle. This is the worker function
     24  for IpSec4(6)DriverbindingSupported.
    2425
    2526  @param[in]  This                 Protocol instance pointer.
     
    2728  @param[in]  RemainingDevicePath  Optional parameter used to pick a specific child
    2829                                   device to start.
    29 
     30  @param[in]  IpVersion            IP_VERSION_4 or IP_VERSION_6.
     31 
    3032  @retval EFI_SUCCES           This driver supports this device.
    3133  @retval EFI_ALREADY_STARTED  This driver is already running on this device.
     
    3537EFI_STATUS
    3638EFIAPI
    37 IpSecDriverBindingSupported (
    38   IN EFI_DRIVER_BINDING_PROTOCOL  *This,
    39   IN EFI_HANDLE                   ControllerHandle,
    40   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath  OPTIONAL
    41   )
    42 {
    43   EFI_STATUS  Udp4Status;
    44   EFI_STATUS  Udp6Status;
    45 
    46   Udp4Status = gBS->OpenProtocol (
    47                       ControllerHandle,
    48                       &gEfiUdp4ServiceBindingProtocolGuid,
    49                       NULL,
    50                       This->DriverBindingHandle,
    51                       ControllerHandle,
    52                       EFI_OPEN_PROTOCOL_TEST_PROTOCOL
    53                       );
    54 
    55   Udp6Status = gBS->OpenProtocol (
    56                       ControllerHandle,
    57                       &gEfiUdp6ServiceBindingProtocolGuid,
    58                       NULL,
    59                       This->DriverBindingHandle,
    60                       ControllerHandle,
    61                       EFI_OPEN_PROTOCOL_TEST_PROTOCOL
    62                       );
    63 
    64   //
    65   // The controller with either Udp4Sb or Udp6Sb is supported.
    66   //
    67   if (!EFI_ERROR (Udp4Status) || !EFI_ERROR (Udp6Status)) {
    68     return EFI_SUCCESS;
    69   }
    70 
    71   return EFI_UNSUPPORTED;
    72 }
    73 
    74 /**
    75   Start this driver on ControllerHandle.
     39IpSecSupported (
     40  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     41  IN EFI_HANDLE                   ControllerHandle,
     42  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath  OPTIONAL,
     43  IN UINT8                        IpVersion
     44  )
     45{
     46  EFI_STATUS  Status;
     47  EFI_GUID    *UdpServiceBindingGuid;
     48 
     49  if (IpVersion == IP_VERSION_4) {
     50    UdpServiceBindingGuid  = &gEfiUdp4ServiceBindingProtocolGuid;
     51  } else {
     52    UdpServiceBindingGuid  = &gEfiUdp6ServiceBindingProtocolGuid;
     53  }
     54
     55  Status = gBS->OpenProtocol (
     56                  ControllerHandle,
     57                  UdpServiceBindingGuid,
     58                  NULL,
     59                  This->DriverBindingHandle,
     60                  ControllerHandle,
     61                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
     62                  );
     63  if (EFI_ERROR (Status)) {
     64    return EFI_UNSUPPORTED;
     65  }
     66  return EFI_SUCCESS;
     67}
     68
     69/**
     70  Start this driver on ControllerHandle. This is the worker function
     71  for IpSec4(6)DriverbindingStart.
    7672
    7773  @param[in]  This                 Protocol instance pointer.
     
    7975  @param[in]  RemainingDevicePath  Optional parameter used to pick a specific child
    8076                                   device to start.
     77  @param[in]  IpVersion            IP_VERSION_4 or IP_VERSION_6.
    8178
    8279  @retval EFI_SUCCES           This driver is added to ControllerHandle
     
    8986EFI_STATUS
    9087EFIAPI
    91 IpSecDriverBindingStart (
    92   IN EFI_DRIVER_BINDING_PROTOCOL  *This,
    93   IN EFI_HANDLE                   ControllerHandle,
    94   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
     88IpSecStart (
     89  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     90  IN EFI_HANDLE                   ControllerHandle,
     91  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL,
     92  IN UINT8                        IpVersion
    9593  )
    9694{
    9795  EFI_IPSEC2_PROTOCOL *IpSec;
    9896  EFI_STATUS          Status;
    99   EFI_STATUS          Udp4Status;
    100   EFI_STATUS          Udp6Status;
    10197  IPSEC_PRIVATE_DATA  *Private;
    10298
     
    112108  Private = IPSEC_PRIVATE_DATA_FROM_IPSEC (IpSec);
    113109
    114   //
    115   // If udp4 sb is on the controller, try to open a udp4 io for input.
    116   //
    117   Udp4Status = gBS->OpenProtocol (
    118                       ControllerHandle,
    119                       &gEfiUdp4ServiceBindingProtocolGuid,
    120                       NULL,
    121                       This->DriverBindingHandle,
    122                       ControllerHandle,
    123                       EFI_OPEN_PROTOCOL_TEST_PROTOCOL
    124                       );
    125 
    126   if (!EFI_ERROR (Udp4Status)) {
    127     Udp4Status = IkeOpenInputUdp4 (Private, ControllerHandle);
    128   }
    129   //
    130   // If udp6 sb is on the controller, try to open a udp6 io for input.
    131   //
    132   Udp6Status = gBS->OpenProtocol (
    133                       ControllerHandle,
    134                       &gEfiUdp6ServiceBindingProtocolGuid,
    135                       NULL,
    136                       This->DriverBindingHandle,
    137                       ControllerHandle,
    138                       EFI_OPEN_PROTOCOL_TEST_PROTOCOL
    139                       );
    140 
    141   if (!EFI_ERROR (Udp6Status)) {
    142     Udp6Status = IkeOpenInputUdp6 (Private, ControllerHandle);
    143   }
    144 
    145   if (!EFI_ERROR (Udp4Status) || !EFI_ERROR (Udp6Status)) {
    146     return EFI_SUCCESS;
    147   }
    148 
    149   return EFI_DEVICE_ERROR;
    150 }
    151 
    152 /**
    153   Stop this driver on ControllerHandle.
     110  if (IpVersion == IP_VERSION_4) {
     111    //
     112    // Try to open a udp4 io for input.
     113    //
     114    Status = gBS->OpenProtocol (
     115                        ControllerHandle,
     116                        &gEfiUdp4ServiceBindingProtocolGuid,
     117                        NULL,
     118                        This->DriverBindingHandle,
     119                        ControllerHandle,
     120                        EFI_OPEN_PROTOCOL_TEST_PROTOCOL
     121                        );
     122
     123    if (!EFI_ERROR (Status)) {
     124      Status = IkeOpenInputUdp4 (Private, ControllerHandle, This->DriverBindingHandle);
     125    }
     126  } else {
     127    //
     128    // Try to open a udp6 io for input.
     129    //
     130    Status = gBS->OpenProtocol (
     131                        ControllerHandle,
     132                        &gEfiUdp6ServiceBindingProtocolGuid,
     133                        NULL,
     134                        This->DriverBindingHandle,
     135                        ControllerHandle,
     136                        EFI_OPEN_PROTOCOL_TEST_PROTOCOL
     137                        );
     138
     139    if (!EFI_ERROR (Status)) {
     140      Status = IkeOpenInputUdp6 (Private, ControllerHandle, This->DriverBindingHandle);
     141    }
     142  }
     143
     144  if (EFI_ERROR (Status)) {
     145    return EFI_DEVICE_ERROR;
     146  }
     147  return EFI_SUCCESS;
     148}
     149
     150/**
     151  Stop this driver on ControllerHandle. This is the worker function
     152  for IpSec4(6)DriverbindingStop.
    154153
    155154  @param[in]  This                 Protocol instance pointer.
     
    158157                                   children is zero, stop the entire bus driver.
    159158  @param[in]  ChildHandleBuffer    List of Child Handles to Stop.
     159  @param[in]  IpVersion            IP_VERSION_4 or IP_VERSION_6.
    160160
    161161  @retval EFI_SUCCES           This driver removed ControllerHandle.
     
    165165EFI_STATUS
    166166EFIAPI
    167 IpSecDriverBindingStop (
     167IpSecStop (
    168168  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
    169169  IN EFI_HANDLE                   ControllerHandle,
    170170  IN UINTN                        NumberOfChildren,
    171   IN EFI_HANDLE                   *ChildHandleBuffer
     171  IN EFI_HANDLE                   *ChildHandleBuffer,
     172  IN UINT8                        IpVersion
    172173  )
    173174{
     
    191192
    192193  //
    193   // Delete all SAs before stop Ipsec.
    194   //
    195   IkeDeleteAllSas (Private, FALSE);
    196   //
    197   // If has udp4 io opened on the controller, close and free it.
    198   //
    199   NET_LIST_FOR_EACH_SAFE (Entry, Next, &Private->Udp4List) {
    200 
    201     UdpSrv = IPSEC_UDP_SERVICE_FROM_LIST (Entry);
    202     //
    203     // Find the right udp service which installed on the appointed nic handle.
    204     //
    205     if (UdpSrv->Input != NULL && ControllerHandle == UdpSrv->Input->UdpHandle) {
    206       UdpIoFreeIo (UdpSrv->Input);
    207       UdpSrv->Input = NULL;
     194  // The SAs are shared by both IP4 and IP6 stack. So we skip the cleanup
     195  // and leave the SAs unchanged if the other IP stack is still running.
     196  //
     197  if ((IpVersion == IP_VERSION_4 && Private->Udp6Num ==0) ||
     198      (IpVersion == IP_VERSION_6 && Private->Udp4Num ==0)) {
     199    IkeDeleteAllSas (Private, FALSE);
     200  }
     201
     202  if (IpVersion == IP_VERSION_4) {
     203    //
     204    // If has udp4 io opened on the controller, close and free it.
     205    //
     206    NET_LIST_FOR_EACH_SAFE (Entry, Next, &Private->Udp4List) {
     207
     208      UdpSrv = IPSEC_UDP_SERVICE_FROM_LIST (Entry);
     209      //
     210      // Find the right udp service which installed on the appointed nic handle.
     211      //
     212      if (UdpSrv->Input != NULL && ControllerHandle == UdpSrv->Input->UdpHandle) {
     213        UdpIoFreeIo (UdpSrv->Input);
     214        UdpSrv->Input = NULL;
     215      }
     216
     217      if (UdpSrv->Output != NULL && ControllerHandle == UdpSrv->Output->UdpHandle) {
     218        UdpIoFreeIo (UdpSrv->Output);
     219        UdpSrv->Output = NULL;
     220      }
     221
     222      if (UdpSrv->Input == NULL && UdpSrv->Output == NULL) {
     223        RemoveEntryList (&UdpSrv->List);
     224        FreePool (UdpSrv);
     225        ASSERT (Private->Udp4Num > 0);
     226        Private->Udp4Num--;
     227      }
    208228    }
    209 
    210     if (UdpSrv->Output != NULL && ControllerHandle == UdpSrv->Output->UdpHandle) {
    211       UdpIoFreeIo (UdpSrv->Output);
    212       UdpSrv->Output = NULL;
     229  } else {
     230    //
     231    // If has udp6 io opened on the controller, close and free it.
     232    //
     233    NET_LIST_FOR_EACH_SAFE (Entry, Next, &Private->Udp6List) {
     234
     235      UdpSrv = IPSEC_UDP_SERVICE_FROM_LIST (Entry);
     236      //
     237      // Find the right udp service which installed on the appointed nic handle.
     238      //
     239      if (UdpSrv->Input != NULL && ControllerHandle == UdpSrv->Input->UdpHandle) {
     240        UdpIoFreeIo (UdpSrv->Input);
     241        UdpSrv->Input = NULL;
     242      }
     243
     244      if (UdpSrv->Output != NULL && ControllerHandle == UdpSrv->Output->UdpHandle) {
     245        UdpIoFreeIo (UdpSrv->Output);
     246        UdpSrv->Output = NULL;
     247      }
     248
     249      if (UdpSrv->Input == NULL && UdpSrv->Output == NULL) {
     250        RemoveEntryList (&UdpSrv->List);
     251        FreePool (UdpSrv);
     252        ASSERT (Private->Udp6Num > 0);
     253        Private->Udp6Num--;
     254      }
    213255    }
    214 
    215     if (UdpSrv->Input == NULL && UdpSrv->Output == NULL) {
    216       RemoveEntryList (&UdpSrv->List);
    217       FreePool (UdpSrv);
    218       ASSERT (Private->Udp4Num > 0);
    219       Private->Udp4Num--;
    220     }
    221   }
    222   //
    223   // If has udp6 io opened on the controller, close and free it.
    224   //
    225   NET_LIST_FOR_EACH_SAFE (Entry, Next, &Private->Udp6List) {
    226 
    227     UdpSrv = IPSEC_UDP_SERVICE_FROM_LIST (Entry);
    228     //
    229     // Find the right udp service which installed on the appointed nic handle.
    230     //
    231     if (UdpSrv->Input != NULL && ControllerHandle == UdpSrv->Input->UdpHandle) {
    232       UdpIoFreeIo (UdpSrv->Input);
    233       UdpSrv->Input = NULL;
    234     }
    235 
    236     if (UdpSrv->Output != NULL && ControllerHandle == UdpSrv->Output->UdpHandle) {
    237       UdpIoFreeIo (UdpSrv->Output);
    238       UdpSrv->Output = NULL;
    239     }
    240 
    241     if (UdpSrv->Input == NULL && UdpSrv->Output == NULL) {
    242       RemoveEntryList (&UdpSrv->List);
    243       FreePool (UdpSrv);
    244       ASSERT (Private->Udp6Num > 0);
    245       Private->Udp6Num--;
    246     }
    247256  }
    248257
     
    250259}
    251260
    252 EFI_DRIVER_BINDING_PROTOCOL gIpSecDriverBinding = {
    253   IpSecDriverBindingSupported,
    254   IpSecDriverBindingStart,
    255   IpSecDriverBindingStop,
     261/**
     262  Test to see if this driver supports ControllerHandle.
     263
     264  @param[in]  This                 Protocol instance pointer.
     265  @param[in]  ControllerHandle     Handle of device to test.
     266  @param[in]  RemainingDevicePath  Optional parameter used to pick a specific child
     267                                   device to start.
     268
     269  @retval EFI_SUCCES           This driver supports this device.
     270  @retval EFI_ALREADY_STARTED  This driver is already running on this device.
     271  @retval other                This driver does not support this device.
     272
     273**/
     274EFI_STATUS
     275EFIAPI
     276IpSec4DriverBindingSupported (
     277  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     278  IN EFI_HANDLE                   ControllerHandle,
     279  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath  OPTIONAL
     280  )
     281{
     282  return IpSecSupported (
     283           This,
     284           ControllerHandle,
     285           RemainingDevicePath,
     286           IP_VERSION_4
     287           );
     288}
     289
     290/**
     291  Start this driver on ControllerHandle.
     292
     293  @param[in]  This                 Protocol instance pointer.
     294  @param[in]  ControllerHandle     Handle of device to bind driver to.
     295  @param[in]  RemainingDevicePath  Optional parameter used to pick a specific child
     296                                   device to start.
     297
     298  @retval EFI_SUCCES           This driver is added to ControllerHandle
     299  @retval EFI_ALREADY_STARTED  This driver is already running on ControllerHandle
     300  @retval EFI_DEVICE_ERROR     The device could not be started due to a device error.
     301                               Currently not implemented.
     302  @retval other                This driver does not support this device
     303
     304**/
     305EFI_STATUS
     306EFIAPI
     307IpSec4DriverBindingStart (
     308  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     309  IN EFI_HANDLE                   ControllerHandle,
     310  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
     311  )
     312{
     313  return IpSecStart (
     314           This,
     315           ControllerHandle,
     316           RemainingDevicePath,
     317           IP_VERSION_4
     318           );
     319}
     320
     321/**
     322  Stop this driver on ControllerHandle.
     323
     324  @param[in]  This                 Protocol instance pointer.
     325  @param[in]  ControllerHandle     Handle of a device to stop the driver on.
     326  @param[in]  NumberOfChildren     Number of Handles in ChildHandleBuffer. If the number of
     327                                   children is zero, stop the entire bus driver.
     328  @param[in]  ChildHandleBuffer    List of Child Handles to Stop.
     329
     330  @retval EFI_SUCCES           This driver removed ControllerHandle.
     331  @retval other                This driver was not removed from this device.
     332
     333**/
     334EFI_STATUS
     335EFIAPI
     336IpSec4DriverBindingStop (
     337  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     338  IN EFI_HANDLE                   ControllerHandle,
     339  IN UINTN                        NumberOfChildren,
     340  IN EFI_HANDLE                   *ChildHandleBuffer
     341  )
     342{
     343  return IpSecStop (
     344           This,
     345           ControllerHandle,
     346           NumberOfChildren,
     347           ChildHandleBuffer,
     348           IP_VERSION_4
     349           );
     350}
     351
     352/**
     353  Test to see if this driver supports ControllerHandle.
     354
     355  @param[in]  This                 Protocol instance pointer.
     356  @param[in]  ControllerHandle     Handle of device to test.
     357  @param[in]  RemainingDevicePath  Optional parameter used to pick a specific child
     358                                   device to start.
     359
     360  @retval EFI_SUCCES           This driver supports this device.
     361  @retval EFI_ALREADY_STARTED  This driver is already running on this device.
     362  @retval other                This driver does not support this device.
     363
     364**/
     365EFI_STATUS
     366EFIAPI
     367IpSec6DriverBindingSupported (
     368  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     369  IN EFI_HANDLE                   ControllerHandle,
     370  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath  OPTIONAL
     371  )
     372{
     373  return IpSecSupported (
     374           This,
     375           ControllerHandle,
     376           RemainingDevicePath,
     377           IP_VERSION_6
     378           );
     379}
     380
     381/**
     382  Start this driver on ControllerHandle.
     383
     384  @param[in]  This                 Protocol instance pointer.
     385  @param[in]  ControllerHandle     Handle of device to bind driver to.
     386  @param[in]  RemainingDevicePath  Optional parameter used to pick a specific child
     387                                   device to start.
     388
     389  @retval EFI_SUCCES           This driver is added to ControllerHandle
     390  @retval EFI_ALREADY_STARTED  This driver is already running on ControllerHandle
     391  @retval EFI_DEVICE_ERROR     The device could not be started due to a device error.
     392                               Currently not implemented.
     393  @retval other                This driver does not support this device
     394
     395**/
     396EFI_STATUS
     397EFIAPI
     398IpSec6DriverBindingStart (
     399  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     400  IN EFI_HANDLE                   ControllerHandle,
     401  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
     402  )
     403{
     404  return IpSecStart (
     405           This,
     406           ControllerHandle,
     407           RemainingDevicePath,
     408           IP_VERSION_6
     409           );
     410}
     411
     412/**
     413  Stop this driver on ControllerHandle.
     414
     415  @param[in]  This                 Protocol instance pointer.
     416  @param[in]  ControllerHandle     Handle of a device to stop the driver on.
     417  @param[in]  NumberOfChildren     Number of Handles in ChildHandleBuffer. If the number of
     418                                   children is zero, stop the entire bus driver.
     419  @param[in]  ChildHandleBuffer    List of Child Handles to Stop.
     420
     421  @retval EFI_SUCCES           This driver removed ControllerHandle.
     422  @retval other                This driver was not removed from this device.
     423
     424**/
     425EFI_STATUS
     426EFIAPI
     427IpSec6DriverBindingStop (
     428  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     429  IN EFI_HANDLE                   ControllerHandle,
     430  IN UINTN                        NumberOfChildren,
     431  IN EFI_HANDLE                   *ChildHandleBuffer
     432  )
     433{
     434  return IpSecStop (
     435           This,
     436           ControllerHandle,
     437           NumberOfChildren,
     438           ChildHandleBuffer,
     439           IP_VERSION_6
     440           );
     441}
     442
     443EFI_DRIVER_BINDING_PROTOCOL gIpSec4DriverBinding = {
     444  IpSec4DriverBindingSupported,
     445  IpSec4DriverBindingStart,
     446  IpSec4DriverBindingStop,
     447  0xa,
     448  NULL,
     449  NULL
     450};
     451
     452EFI_DRIVER_BINDING_PROTOCOL gIpSec6DriverBinding = {
     453  IpSec6DriverBindingSupported,
     454  IpSec6DriverBindingStart,
     455  IpSec6DriverBindingStop,
    256456  0xa,
    257457  NULL,
     
    387587             ImageHandle,
    388588             SystemTable,
    389              &gIpSecDriverBinding,
     589             &gIpSec4DriverBinding,
    390590             ImageHandle,
    391591             &gIpSecComponentName,
     
    396596  }
    397597
     598  Status = EfiLibInstallDriverBindingComponentName2 (
     599             ImageHandle,
     600             SystemTable,
     601             &gIpSec6DriverBinding,
     602             NULL,
     603             &gIpSecComponentName,
     604             &gIpSecComponentName2
     605             );
     606  if (EFI_ERROR (Status)) {
     607    goto ON_UNINSTALL_IPSEC4_DB;
     608  }
     609
    398610  return Status;
     611
     612ON_UNINSTALL_IPSEC4_DB:
     613  gBS->UninstallMultipleProtocolInterfaces (
     614         ImageHandle,
     615         &gEfiDriverBindingProtocolGuid,
     616         &gIpSec4DriverBinding,
     617         &gEfiComponentName2ProtocolGuid,
     618         &gIpSecComponentName2,
     619         &gEfiComponentNameProtocolGuid,
     620         &gIpSecComponentName,
     621         NULL
     622         );
    399623
    400624ON_UNINSTALL_IPSEC:
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/IpSecDxe/IpSecDxe.inf

    r48674 r58459  
    11## @file
    2 Component description file for IpSec module.
     2Packet-level security for IP datagram.
    33#
    4 #  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4#  This driver provides EFI IPsec2 Protocol which is used to abstract the ability
     5#  to deal with the individual packets sent and received by the host and provide
     6#  packet-level security for IP datagram. It provides the IP packet protection via
     7#  ESP and it supports IKEv2 for key negotiation.
     8#
     9#  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    510#
    611#  This program and the accompanying materials
     
    2227
    2328  ENTRY_POINT                    = IpSecDriverEntryPoint
     29  MODULE_UNI_FILE                = IpSecDxe.uni
    2430
    2531#
     
    8490 
    8591[Protocols]
    86   gEfiIp4ConfigProtocolGuid                     # PROTOCOL ALWAYS_CONSUMED
    87   gEfiUdp4ServiceBindingProtocolGuid            # PROTOCOL ALWAYS_CONSUMED 
    88   gEfiUdp4ProtocolGuid                          # PROTOCOL ALWAYS_CONSUMED
    89   gEfiUdp6ServiceBindingProtocolGuid            # PROTOCOL ALWAYS_CONSUMED 
    90   gEfiUdp6ProtocolGuid                          # PROTOCOL ALWAYS_CONSUMED
    91   gEfiIpSecConfigProtocolGuid                   # PROTOCOL ALWAYS_PRODUCED
    92   gEfiIpSec2ProtocolGuid                        # PROTOCOL ALWAYS_PRODUCED
     92  gEfiIp4ConfigProtocolGuid                     ## SOMETIMES_CONSUMES
     93  gEfiUdp4ServiceBindingProtocolGuid            ## SOMETIMES_CONSUMES 
     94  gEfiUdp4ProtocolGuid                          ## SOMETIMES_CONSUMES
     95  gEfiUdp6ServiceBindingProtocolGuid            ## SOMETIMES_CONSUMES 
     96  gEfiUdp6ProtocolGuid                          ## SOMETIMES_CONSUMES
     97  gEfiIpSecConfigProtocolGuid                   ## PRODUCES
     98  gEfiIpSec2ProtocolGuid                        ## PRODUCES
    9399 
    94100[Pcd]
    95   gEfiNetworkPkgTokenSpaceGuid.PcdIpsecCertificateEnabled
    96   gEfiNetworkPkgTokenSpaceGuid.PcdIpsecUefiCaFile
    97   gEfiNetworkPkgTokenSpaceGuid.PcdIpsecUefiCaFileSize
    98   gEfiNetworkPkgTokenSpaceGuid.PcdIpsecUefiCertificate
    99   gEfiNetworkPkgTokenSpaceGuid.PcdIpsecUefiCertificateSize
    100   gEfiNetworkPkgTokenSpaceGuid.PcdIpsecUefiCertificateKey
    101   gEfiNetworkPkgTokenSpaceGuid.PcdIpsecUefiCertificateKeySize
     101  gEfiNetworkPkgTokenSpaceGuid.PcdIpsecCertificateEnabled       ## SOMETIMES_CONSUMES
     102  gEfiNetworkPkgTokenSpaceGuid.PcdIpsecUefiCaFile               ## SOMETIMES_CONSUMES
     103  gEfiNetworkPkgTokenSpaceGuid.PcdIpsecUefiCaFileSize           ## SOMETIMES_CONSUMES
     104  gEfiNetworkPkgTokenSpaceGuid.PcdIpsecUefiCertificate          ## SOMETIMES_CONSUMES
     105  gEfiNetworkPkgTokenSpaceGuid.PcdIpsecUefiCertificateSize      ## SOMETIMES_CONSUMES
     106  gEfiNetworkPkgTokenSpaceGuid.PcdIpsecUefiCertificateKey       ## SOMETIMES_CONSUMES
     107  gEfiNetworkPkgTokenSpaceGuid.PcdIpsecUefiCertificateKeySize   ## SOMETIMES_CONSUMES
     108
     109[UserExtensions.TianoCore."ExtraFiles"]
     110  IpSecDxeExtra.uni
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Mtftp6Dxe/ComponentName.c

    r48674 r58459  
    22  UEFI Component Name(2) protocol implementation for Mtftp6 driver.
    33
    4   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    170170  }
    171171};
     172
     173GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE   *gMtftp6ControllerNameTable = NULL;
    172174
    173175/**
     
    228230
    229231/**
     232  Update the component name for the Mtftp6 child handle.
     233
     234  @param  Mtftp6[in]                A pointer to the EFI_MTFTP6_PROTOCOL.
     235
     236 
     237  @retval EFI_SUCCESS               Update the ControllerNameTable of this instance successfully.
     238  @retval EFI_INVALID_PARAMETER     The input parameter is invalid.
     239 
     240**/
     241EFI_STATUS
     242UpdateName (
     243  IN    EFI_MTFTP6_PROTOCOL             *Mtftp6
     244  )
     245{
     246  EFI_STATUS                       Status;
     247  CHAR16                           HandleName[128];
     248  EFI_MTFTP6_MODE_DATA             Mtftp6ModeData;
     249  CHAR16                           Address[sizeof"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"];
     250
     251  if (Mtftp6 == NULL) {
     252    return EFI_INVALID_PARAMETER;
     253  }
     254
     255  //
     256  // Format the child name into the string buffer.
     257  //
     258  Status = Mtftp6->GetModeData (Mtftp6, &Mtftp6ModeData);
     259  if (!EFI_ERROR (Status)) {
     260    Status = NetLibIp6ToStr (&Mtftp6ModeData.ConfigData.ServerIp, Address, sizeof(Address));
     261    if (EFI_ERROR (Status)) {
     262      return Status;
     263    }
     264    UnicodeSPrint (HandleName, sizeof (HandleName),
     265      L"MTFTPv6(ServerIp=%s, InitialServerPort=%d)",
     266      Address,
     267      Mtftp6ModeData.ConfigData.InitialServerPort
     268      );
     269  } else {
     270    UnicodeSPrint (HandleName, 0x100, L"MTFTPv6(%r)", Status);
     271  }
     272
     273  if (gMtftp6ControllerNameTable != NULL) {
     274    FreeUnicodeStringTable (gMtftp6ControllerNameTable);
     275    gMtftp6ControllerNameTable = NULL;
     276  }
     277 
     278  Status = AddUnicodeString2 (
     279             "eng",
     280             gMtftp6ComponentName.SupportedLanguages,
     281             &gMtftp6ControllerNameTable,
     282             HandleName,
     283             TRUE
     284             );
     285  if (EFI_ERROR (Status)) {
     286    return Status;
     287  }
     288 
     289  return AddUnicodeString2 (
     290           "en",
     291           gMtftp6ComponentName2.SupportedLanguages,
     292           &gMtftp6ControllerNameTable,
     293           HandleName,
     294           FALSE
     295           );
     296}
     297
     298
     299/**
    230300  Retrieves a Unicode string that is the user-readable name of the controller
    231301  that is being managed by a driver.
     
    305375  )
    306376{
    307   return EFI_UNSUPPORTED;
     377  EFI_STATUS                    Status;
     378  EFI_MTFTP6_PROTOCOL           *Mtftp6;
     379
     380  //
     381  // Only provide names for child handles.
     382  //
     383  if (ChildHandle == NULL) {
     384    return EFI_UNSUPPORTED;
     385  }
     386 
     387  //
     388  // Make sure this driver produced ChildHandle
     389  //
     390  Status = EfiTestChildHandle (
     391             ControllerHandle,
     392             ChildHandle,
     393             &gEfiUdp6ProtocolGuid
     394             );
     395  if (EFI_ERROR (Status)) {
     396    return Status;
     397  }
     398
     399  //
     400  // Retrieve an instance of a produced protocol from ChildHandle
     401  //
     402  Status = gBS->OpenProtocol (
     403                  ChildHandle,
     404                  &gEfiMtftp6ProtocolGuid,
     405                  (VOID **)&Mtftp6,
     406                  NULL,
     407                  NULL,
     408                  EFI_OPEN_PROTOCOL_GET_PROTOCOL
     409                  );
     410  if (EFI_ERROR (Status)) {
     411    return Status;
     412  }
     413
     414  //
     415  // Update the component name for this child handle.
     416  //
     417  Status = UpdateName (Mtftp6);
     418  if (EFI_ERROR (Status)) {
     419    return Status;
     420  }
     421
     422  return LookupUnicodeString2 (
     423           Language,
     424           This->SupportedLanguages,
     425           gMtftp6ControllerNameTable,
     426           ControllerName,
     427           (BOOLEAN)(This == &gMtftp6ComponentName)
     428           );
    308429}
     430
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Mtftp6Dxe/Mtftp6Driver.c

    r48674 r58459  
    33  implementation for Mtftp6 Driver.
    44
    5   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     5  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    66
    77  This program and the accompanying materials
     
    3434
    3535/**
    36   Destory the MTFTP6 service. The MTFTP6 service may be partly initialized,
     36  Destroy the MTFTP6 service. The MTFTP6 service may be partly initialized,
    3737  or partly destroyed. If a resource is destroyed, it is marked as such in
    3838  case the destroy failed and is called again later.
     
    4747{
    4848  //
    49   // Make sure all children instances have been already destoryed.
     49  // Make sure all children instances have been already destroyed.
    5050  //
    5151  ASSERT (Service->ChildrenNum == 0);
     
    9999  Mtftp6Srv->Controller     = Controller;
    100100  Mtftp6Srv->Image          = Image;
    101   Mtftp6Srv->InDestory      = FALSE;
    102101  Mtftp6Srv->ChildrenNum    = 0;
    103102
     
    220219
    221220  Mtftp6Ins->Signature = MTFTP6_INSTANCE_SIGNATURE;
    222   Mtftp6Ins->InDestory = FALSE;
     221  Mtftp6Ins->InDestroy = FALSE;
    223222  Mtftp6Ins->Service   = Service;
    224223
     
    235234
    236235  return EFI_SUCCESS;
     236}
     237
     238
     239/**
     240  Callback function which provided by user to remove one node in NetDestroyLinkList process.
     241 
     242  @param[in]    Entry           The entry to be removed.
     243  @param[in]    Context         Pointer to the callback context corresponds to the Context in NetDestroyLinkList.
     244
     245  @retval EFI_SUCCESS           The entry has been removed successfully.
     246  @retval Others                Fail to remove the entry.
     247
     248**/
     249EFI_STATUS
     250EFIAPI
     251Mtftp6DestroyChildEntryInHandleBuffer (
     252  IN LIST_ENTRY         *Entry,
     253  IN VOID               *Context
     254  )
     255{
     256  MTFTP6_INSTANCE               *Instance;
     257  EFI_SERVICE_BINDING_PROTOCOL  *ServiceBinding;
     258  UINTN                         NumberOfChildren;
     259  EFI_HANDLE                    *ChildHandleBuffer;
     260
     261  if (Entry == NULL || Context == NULL) {
     262    return EFI_INVALID_PARAMETER;
     263  }
     264
     265  Instance = NET_LIST_USER_STRUCT_S (Entry, MTFTP6_INSTANCE, Link, MTFTP6_INSTANCE_SIGNATURE);
     266  ServiceBinding    = ((MTFTP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding;
     267  NumberOfChildren  = ((MTFTP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren;
     268  ChildHandleBuffer = ((MTFTP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer;
     269
     270  if (!NetIsInHandleBuffer (Instance->Handle, NumberOfChildren, ChildHandleBuffer)) {
     271    return EFI_SUCCESS;
     272  }
     273
     274  return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);
    237275}
    238276
     
    430468  )
    431469{
    432   EFI_SERVICE_BINDING_PROTOCOL  *ServiceBinding;
    433   MTFTP6_SERVICE                *Service;
    434   MTFTP6_INSTANCE               *Instance;
    435   EFI_HANDLE                    NicHandle;
    436   EFI_STATUS                    Status;
    437   EFI_TPL                       OldTpl;
    438 
     470  EFI_SERVICE_BINDING_PROTOCOL               *ServiceBinding;
     471  MTFTP6_SERVICE                             *Service;
     472  EFI_HANDLE                                 NicHandle;
     473  EFI_STATUS                                 Status;
     474  LIST_ENTRY                                 *List;
     475  MTFTP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context;
     476 
    439477  //
    440478  // Locate the Nic handle to retrieve the Mtftp6 private data.
     
    443481
    444482  if (NicHandle == NULL) {
    445     return EFI_DEVICE_ERROR;
     483    return EFI_SUCCESS;
    446484  }
    447485
     
    461499  Service = MTFTP6_SERVICE_FROM_THIS (ServiceBinding);
    462500
    463   if (Service->InDestory) {
    464     return EFI_SUCCESS;
    465   }
    466 
    467   OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
    468 
    469   if (NumberOfChildren == 0) {
     501  if (!IsListEmpty (&Service->Children)) {
    470502    //
    471     // Destory the Mtftp6 service if there is no Mtftp6 child instance left.
     503    // Destroy the Mtftp6 child instance in ChildHandleBuffer.
    472504    //
    473     Service->InDestory = TRUE;
    474 
     505    List = &Service->Children;
     506    Context.ServiceBinding    = ServiceBinding;
     507    Context.NumberOfChildren  = NumberOfChildren;
     508    Context.ChildHandleBuffer = ChildHandleBuffer;
     509    Status = NetDestroyLinkList (
     510               List,
     511               Mtftp6DestroyChildEntryInHandleBuffer,
     512               &Context,
     513               NULL
     514               );
     515  }
     516
     517  if (NumberOfChildren == 0 && IsListEmpty (&Service->Children)) {
     518    //
     519    // Destroy the Mtftp6 service if there is no Mtftp6 child instance left.
     520    //
    475521    gBS->UninstallProtocolInterface (
    476522           NicHandle,
     
    480526
    481527    Mtftp6DestroyService (Service);
    482 
    483   } else {
    484     //
    485     // Destory the Mtftp6 child instance one by one.
    486     //
    487     while (!IsListEmpty (&Service->Children)) {
    488       Instance = NET_LIST_HEAD (&Service->Children, MTFTP6_INSTANCE, Link);
    489       Mtftp6ServiceBindingDestroyChild (ServiceBinding, Instance->Handle);
    490     }
    491 
    492     if (Service->ChildrenNum != 0) {
    493       Status = EFI_DEVICE_ERROR;
    494     }
    495   }
    496 
    497   gBS->RestoreTPL (OldTpl);
     528    Status = EFI_SUCCESS;
     529  }
     530
    498531  return Status;
    499532}
     
    658691
    659692  //
    660   // Check whether the instance already in destory state.
    661   //
    662   if (Instance->InDestory) {
     693  // Check whether the instance already in Destroy state.
     694  //
     695  if (Instance->InDestroy) {
    663696    return EFI_SUCCESS;
    664697  }
     
    666699  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
    667700
    668   Instance->InDestory = TRUE;
     701  Instance->InDestroy = TRUE;
    669702
    670703  gBS->CloseProtocol (
     
    675708         );
    676709
     710  if (Instance->UdpIo != NULL) {
     711    gBS->CloseProtocol (
     712         Instance->UdpIo->UdpHandle,
     713         &gEfiUdp6ProtocolGuid,
     714         gMtftp6DriverBinding.DriverBindingHandle,
     715         Instance->Handle
     716         );
     717  }
     718
     719  if (Instance->McastUdpIo != NULL) {
     720    gBS->CloseProtocol (
     721           Instance->McastUdpIo->UdpHandle,
     722           &gEfiUdp6ProtocolGuid,
     723           gMtftp6DriverBinding.DriverBindingHandle,
     724           Instance->Handle
     725           );
     726  }
     727
    677728  //
    678729  // Uninstall the MTFTP6 protocol first to enable a top down destruction.
    679730  //
     731  gBS->RestoreTPL (OldTpl);
    680732  Status = gBS->UninstallProtocolInterface (
    681733                  ChildHandle,
     
    683735                  Mtftp6
    684736                  );
    685 
    686   if (EFI_ERROR (Status)) {
    687     Instance->InDestory = FALSE;
     737  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
     738  if (EFI_ERROR (Status)) {
     739    Instance->InDestroy = FALSE;
    688740    gBS->RestoreTPL (OldTpl);
    689741    return Status;
     
    696748  Service->ChildrenNum --;
    697749
     750  gBS->RestoreTPL (OldTpl);
     751
    698752  Mtftp6DestroyInstance (Instance);
    699753
    700   gBS->RestoreTPL (OldTpl);
    701 
    702754  return EFI_SUCCESS;
    703755}
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Mtftp6Dxe/Mtftp6Driver.h

    r48674 r58459  
    33  declaration for Mtftp6 Driver.
    44
    5   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     5  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    66
    77  This program and the accompanying materials
     
    2222extern EFI_COMPONENT_NAME_PROTOCOL  gMtftp6ComponentName;
    2323extern EFI_COMPONENT_NAME2_PROTOCOL gMtftp6ComponentName2;
     24extern EFI_UNICODE_STRING_TABLE     *gMtftp6ControllerNameTable;
    2425
    2526/**
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Mtftp6Dxe/Mtftp6Dxe.inf

    r48674 r58459  
    11## @file
    2 #  Component description file for Mtftp6 module.
     2#  Client-side Mtftp6 service.
    33#
    4 #  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     4#  This module produces EFI MTFTPv6 Protocol which provides basic services for
     5#  client-side unicast and/or multicast TFTP.
     6#
     7#  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    58#
    69#  This program and the accompanying materials
     
    2225  ENTRY_POINT                    = Mtftp6DriverEntryPoint
    2326  UNLOAD_IMAGE                   = NetLibDefaultUnload
     27  MODULE_UNI_FILE                = Mtftp6Dxe.uni
     28
    2429#
    2530# The following information is for reference only and not required by the build tools.
     
    6368
    6469[Protocols]
    65   gEfiUdp6ServiceBindingProtocolGuid
    66   gEfiUdp6ProtocolGuid
    67   gEfiMtftp6ServiceBindingProtocolGuid
    68   gEfiMtftp6ProtocolGuid
     70  gEfiUdp6ServiceBindingProtocolGuid                ## TO_START
     71  gEfiUdp6ProtocolGuid                              ## TO_START
     72  gEfiMtftp6ServiceBindingProtocolGuid              ## BY_START
     73  gEfiMtftp6ProtocolGuid                            ## BY_START
    6974
     75[UserExtensions.TianoCore."ExtraFiles"]
     76  Mtftp6DxeExtra.uni
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Mtftp6Dxe/Mtftp6Impl.c

    r48674 r58459  
    99   RFC2349 - TFTP Timeout Interval and Transfer Size Options
    1010
    11   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     11  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    1212
    1313  This program and the accompanying materials
     
    190190    // the configuration, so delay udpio configuration in each operation.
    191191    //
    192     Instance->UdpIo = UdpIoCreateIo (
    193                         Service->Controller,
     192    if (Instance->UdpIo == NULL) {
     193      Instance->UdpIo = UdpIoCreateIo (
     194                          Service->Controller,
     195                          Service->Image,
     196                          Mtftp6ConfigDummyUdpIo,
     197                          UDP_IO_UDP6_VERSION,
     198                          NULL
     199                          );
     200      if (Instance->UdpIo != NULL) {
     201        Status = gBS->OpenProtocol (
     202                        Instance->UdpIo->UdpHandle,
     203                        &gEfiUdp6ProtocolGuid,
     204                        (VOID **) &Udp6,
    194205                        Service->Image,
    195                         Mtftp6ConfigDummyUdpIo,
    196                         UDP_IO_UDP6_VERSION,
    197                         NULL
     206                        Instance->Handle,
     207                        EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
    198208                        );
     209        if (EFI_ERROR (Status)) {
     210          goto ON_EXIT;
     211        }
     212      }
     213    }
    199214
    200215    if (Instance->UdpIo == NULL) {
     
    621636
    622637  //
    623   // Check the instance whether configured or in destory.
     638  // Check the instance whether configured or in destroy.
    624639  //
    625640  if (Instance->Config == NULL) {
    626641    return EFI_NOT_STARTED;
    627   } else if (Instance->InDestory) {
    628     return EFI_DEVICE_ERROR;
    629642  }
    630643
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Mtftp6Dxe/Mtftp6Impl.h

    r48674 r58459  
    22  Mtftp6 internal data structure and definition declaration.
    33
    4   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>
     4  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved. <BR>
    55
    66  This program and the accompanying materials
     
    3030#include <Library/BaseLib.h>
    3131#include <Library/NetLib.h>
     32#include <Library/PrintLib.h>
    3233
    3334typedef struct _MTFTP6_SERVICE  MTFTP6_SERVICE;
     
    9596  BOOLEAN                       IsTransmitted;
    9697  BOOLEAN                       IsMaster;
    97   BOOLEAN                       InDestory;
     98  BOOLEAN                       InDestroy;
    9899};
    99100
     
    118119  //
    119120  UDP_IO                        *DummyUdpIo;
    120   BOOLEAN                       InDestory;
    121121};
     122
     123typedef struct {
     124  EFI_SERVICE_BINDING_PROTOCOL  *ServiceBinding;
     125  UINTN                         NumberOfChildren;
     126  EFI_HANDLE                    *ChildHandleBuffer;
     127} MTFTP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT;
    122128
    123129/**
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Mtftp6Dxe/Mtftp6Rrq.c

    r48674 r58459  
    22  Mtftp6 Rrq process functions implementation.
    33
    4   Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    6060  //
    6161  Instance->CurRetry = 0;
     62  Instance->LastPacket = Packet;
    6263
    6364  return Mtftp6TransmitPacket (Instance, Packet);
     
    454455  EFI_STATUS                Status;
    455456  INTN                      Expected;
     457  EFI_UDP6_PROTOCOL         *Udp6;
    456458
    457459  *IsCompleted = FALSE;
     460  Options = NULL;
    458461
    459462  //
     
    548551
    549552      Instance->McastPort  = ExtInfo.McastPort;
    550       Instance->McastUdpIo = UdpIoCreateIo (
    551                                Instance->Service->Controller,
    552                                Instance->Service->Image,
    553                                Mtftp6RrqConfigMcastUdpIo,
    554                                UDP_IO_UDP6_VERSION,
    555                                Instance
    556                                );
     553      if (Instance->McastUdpIo == NULL) {
     554        Instance->McastUdpIo = UdpIoCreateIo (
     555                                 Instance->Service->Controller,
     556                                 Instance->Service->Image,
     557                                 Mtftp6RrqConfigMcastUdpIo,
     558                                 UDP_IO_UDP6_VERSION,
     559                                 Instance
     560                                 );
     561        if (Instance->McastUdpIo != NULL) {
     562          Status = gBS->OpenProtocol (
     563                          Instance->McastUdpIo->UdpHandle,
     564                          &gEfiUdp6ProtocolGuid,
     565                          (VOID **) &Udp6,
     566                          Instance->Service->Image,
     567                          Instance->Handle,
     568                          EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
     569                          );
     570          if (EFI_ERROR (Status)) {
     571            UdpIoFreeIo (Instance->McastUdpIo);
     572            Instance->McastUdpIo = NULL;
     573            return EFI_DEVICE_ERROR;
     574          }
     575        }
     576      }
    557577
    558578      if (Instance->McastUdpIo == NULL) {
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Mtftp6Dxe/Mtftp6Support.c

    r48674 r58459  
    22  Mtftp6 support functions implementation.
    33
    4   Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    904904
    905905  if (Instance->McastUdpIo != NULL) {
     906    gBS->CloseProtocol (
     907           Instance->McastUdpIo->UdpHandle,
     908           &gEfiUdp6ProtocolGuid,
     909           Instance->McastUdpIo->Image,
     910           Instance->Handle
     911           );
    906912    UdpIoFreeIo (Instance->McastUdpIo);
    907913    Instance->McastUdpIo = NULL;
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Mtftp6Dxe/Mtftp6Wrq.c

    r48674 r58459  
    22  Mtftp6 Wrq process functions implementation.
    33
    4   Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    296296
    297297  *IsCompleted = FALSE;
     298  Options = NULL;
    298299
    299300  //
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/NetworkPkg.dec

    r48674 r58459  
    11## @file
     2# Network Package.
    23#
    3 # This package provides network modules that conform to UEFI 2.2 specification.
     4# This package provides network modules that conform to UEFI 2.4 specification.
    45#
    5 # Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     6# Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
    67#
    78# This program and the accompanying materials are licensed and made available under
     
    1920  PACKAGE_NAME                   = NetworkPkg
    2021  PACKAGE_GUID                   = 947988BE-8D5C-471a-893D-AD181C46BEBB
    21   PACKAGE_VERSION                = 0.93
     22  PACKAGE_VERSION                = 0.95
     23  PACKAGE_UNI_FILE               = NetworkPkg.uni
    2224
    2325[Includes]
     
    3638
    3739[PcdsFeatureFlag]
    38   ## If true, the IKEv2 Certificate Authentication feature is enabled.
     40  ## Indicates if the IPsec IKEv2 Certificate Authentication feature is enabled or not.<BR><BR>
     41  #   TRUE  - Certificate Authentication feature is enabled.<BR>
     42  #   FALSE - Does not support Certificate Authentication.<BR>
     43  # @Prompt Enable IPsec IKEv2 Certificate Authentication.
    3944  gEfiNetworkPkgTokenSpaceGuid.PcdIpsecCertificateEnabled|TRUE|BOOLEAN|0x00000007
    4045
    41 [PcdsFixedAtBuild]
    42   ## Indicates the CA certificate used by IPsec.
     46[PcdsFixedAtBuild, PcdsPatchableInModule]
     47  ## CA certificate used by IPsec.
     48  # @Prompt CA file.
    4349  gEfiNetworkPkgTokenSpaceGuid.PcdIpsecUefiCaFile|{0x30, 0x82, 0x02, 0x76, 0x30, 0x82, 0x01, 0xDF, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00, 0x80, 0x1D, 0xB9, 0x63, 0x93, 0x7C, 0x9D, 0xE0, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x04, 0x05, 0x00, 0x30, 0x74, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0A, 0x4D, 0x79, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x43, 0x41, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x02, 0x48, 0x5A, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x43, 0x4E, 0x31, 0x1C, 0x30, 0x1A, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x01, 0x16, 0x0D, 0x74, 0x65, 0x73, 0x74, 0x40, 0x63, 0x65, 0x72, 0x74, 0x2E, 0x63, 0x6F, 0x6D, 0x31, 0x25, 0x30, 0x23, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x13, 0x1C, 0x52, 0x6F, 0x6F, 0x74, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74,  0x69, 0x6F, 0x6E, 0x20, 0x41, 0x75, 0x74, 0x68, 0x6F, 0x72, 0x69, 0x74, 0x79, 0x30, 0x1E, 0x17, 0x0D, 0x31, 0x30, 0x31, 0x31, 0x30, 0x31, 0x30, 0x31, 0x35, 0x33, 0x33, 0x37, 0x5A, 0x17, 0x0D, 0x31, 0x31, 0x31, 0x31, 0x30, 0x31, 0x30, 0x31, 0x35, 0x33, 0x33, 0x37, 0x5A, 0x30, 0x74, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0A, 0x4D, 0x79, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x43, 0x41, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x02, 0x48, 0x5A, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x43, 0x4E, 0x31, 0x1C, 0x30, 0x1A, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x01, 0x16, 0x0D, 0x74, 0x65, 0x73, 0x74, 0x40, 0x63, 0x65, 0x72, 0x74, 0x2E, 0x63, 0x6F, 0x6D, 0x31, 0x25, 0x30, 0x23,  0x06, 0x03, 0x55, 0x04, 0x0A, 0x13, 0x1C, 0x52, 0x6F, 0x6F, 0x74, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x20, 0x41, 0x75, 0x74, 0x68, 0x6F, 0x72, 0x69, 0x74, 0x79, 0x30, 0x81, 0x9F, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8D, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xFC, 0x80, 0x5D, 0x32, 0x55, 0xC7, 0x4C, 0xC6, 0xA8, 0x2F, 0xF7, 0xEC, 0x1F, 0x75, 0x48, 0x02, 0x79, 0xEB, 0xDF, 0x17, 0x1B, 0x08, 0xBA, 0x21, 0xDD, 0xE5, 0x43, 0x06, 0xE8, 0x81, 0xC5, 0x50,  0x3C, 0x18, 0xDD, 0x53, 0xF4, 0xC9, 0xC9, 0xE1, 0x7A, 0xD3, 0xB3, 0x99, 0xA7, 0xC6, 0x43, 0x2A, 0x51, 0x65, 0x10, 0x93, 0xBA, 0x5F, 0x48, 0xAC, 0x54, 0x12, 0x70, 0x9E, 0xF2, 0x9E, 0x7D, 0xF7,  0x22, 0xAA, 0xB7, 0x19, 0xDE, 0xA9, 0x4D, 0x55, 0xAA, 0x41, 0x8F, 0x08, 0xBD, 0x74, 0xFA, 0xE5,  0x57, 0x13, 0xB4, 0x30, 0x9A, 0xBA, 0x56, 0x01, 0x55, 0x8A, 0x9B, 0x5B, 0x50, 0x29, 0x82, 0xF9,  0x00, 0x69, 0x7E, 0x7B, 0x91, 0xA7, 0x2D, 0x48, 0x1A, 0x93, 0x7C, 0xA2, 0xF9, 0x06, 0x64, 0x4B, 0x80, 0xF8, 0x47, 0x58, 0x45, 0x90, 0x09, 0xEA, 0xD6, 0x7B, 0x85, 0x49, 0x2A, 0x4E, 0xB6, 0x71, 0x02, 0x03, 0x01, 0x00, 0x01, 0xA3, 0x10, 0x30, 0x0E, 0x30, 0x0C, 0x06, 0x03, 0x55, 0x1D, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xFF, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x04, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, 0xEF, 0x38, 0x6A, 0x43, 0x1C, 0x1D, 0x37, 0xBD, 0xF7, 0xCF, 0x15, 0x6A, 0x99, 0x44, 0xE1, 0xFC, 0x68, 0x6E, 0x91, 0x31, 0x9C, 0x1E,  0x8C, 0x1F, 0x72, 0x4B, 0x93, 0x16, 0x1F, 0x06, 0xFE, 0x94, 0xA9, 0x41, 0x64, 0x81, 0xFD, 0xFF,  0xE7, 0x27, 0x4D, 0xE7, 0x59, 0x55, 0xE1, 0x20, 0x14, 0x07, 0x3C, 0x26, 0x78, 0xB0, 0x72, 0x48, 0x76, 0x0C, 0x8B, 0x3F, 0x08, 0xD0, 0x75, 0x7D, 0x76, 0xA4, 0xB5, 0x56, 0xA6, 0xC9, 0x88, 0x17, 0x27, 0x95, 0x85, 0xEE, 0x42, 0x1E, 0x15, 0x0B, 0x05, 0xDC, 0x2F, 0x97, 0x7B, 0x26, 0x82, 0x62, 0x23, 0xDF, 0xBF, 0x55, 0x09, 0xBF, 0x5E, 0x28, 0x1A, 0xCA, 0x1B, 0xEC, 0xA4, 0x81, 0xB7, 0x9D, 0x91, 0xC9, 0x60, 0x5B, 0x29, 0x2B, 0x4C, 0x6F, 0x8B, 0xCC, 0x17, 0xA8, 0xD6, 0x5D, 0x6B, 0xBC, 0x0D, 0x03, 0x31, 0xB0, 0x57, 0xC9, 0xF8, 0x59, 0x88, 0x3D}|VOID*|0x00000001
    4450
    45   ## Indicates the CA certificate file's size.
     51  ## CA certificate file's size.
     52  # @Prompt CA file's size.
    4653  gEfiNetworkPkgTokenSpaceGuid.PcdIpsecUefiCaFileSize|0x0000027A|UINT32|0x00000002
    4754
    48   ## Indicates the X509 certificate as Public Key which is used by IPsec (DER format).
     55  ## X509 certificate as Public Key which is used by IPsec (DER format)
     56  # @Prompt Pubic Key for remote peer.
    4957  gEfiNetworkPkgTokenSpaceGuid.PcdIpsecUefiCertificate|{0x30, 0x82, 0x02, 0x4D, 0x30, 0x82, 0x01, 0xB6, 0x02, 0x01, 0x01, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x04, 0x05, 0x00, 0x30, 0x74, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0A, 0x4D, 0x79, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x43, 0x41, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x02, 0x48, 0x5A, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x43, 0x4E, 0x31, 0x1C, 0x30, 0x1A, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x01, 0x16, 0x0D, 0x74, 0x65, 0x73, 0x74, 0x40, 0x63, 0x65, 0x72, 0x74, 0x2E, 0x63, 0x6F, 0x6D, 0x31, 0x25, 0x30, 0x23, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x13, 0x1C, 0x52, 0x6F, 0x6F, 0x74, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x20, 0x41, 0x75, 0x74, 0x68, 0x6F, 0x72, 0x69, 0x74, 0x79, 0x30, 0x1E, 0x17, 0x0D, 0x31, 0x30, 0x31, 0x31, 0x30, 0x31, 0x30, 0x32, 0x30, 0x34, 0x35, 0x39, 0x5A, 0x17, 0x0D, 0x31, 0x31, 0x31, 0x31, 0x30, 0x31, 0x30, 0x32, 0x30, 0x34, 0x35, 0x39, 0x5A, 0x30, 0x6A, 0x31, 0x0D, 0x30, 0x0B, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x04, 0x55, 0x45, 0x46, 0x49, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x08, 0x13, 0x02, 0x53, 0x48, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x43, 0x4E, 0x31, 0x23, 0x30, 0x21, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x01, 0x16, 0x14, 0x75, 0x65, 0x66, 0x69, 0x2E, 0x74, 0x69, 0x61, 0x6E, 0x6F, 0x40, 0x69, 0x6E, 0x74, 0x65, 0x6C, 0x2E, 0x63, 0x6F, 0x6D, 0x31, 0x0C, 0x30, 0x0A, 0x06, 0x03, 0x55, 0x04, 0x0B, 0x13, 0x03, 0x53, 0x53, 0x47, 0x31, 0x0C, 0x30, 0x0A, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x13, 0x03, 0x53, 0x53, 0x47, 0x30, 0x81, 0x9F, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8D, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xE9, 0x90, 0x47, 0x0D, 0x79, 0x93, 0xED, 0xF5, 0xBD, 0xC9, 0x56, 0x03, 0xDF, 0xE2, 0x71, 0xA9, 0x42, 0x3B, 0x20, 0x1E, 0xAF, 0x88, 0x9D, 0x3F, 0xE1, 0xDE, 0x61, 0xEE, 0x83, 0xC4, 0x2E, 0x48, 0x7A, 0x1F, 0x86, 0x54, 0xD2, 0xD5, 0x61, 0x94, 0xE1, 0x15, 0x79, 0x65, 0xCB, 0x39, 0xEE, 0x78, 0x68, 0x3D, 0x2C, 0xEB, 0xE4, 0x7A, 0x8D, 0x98, 0x14, 0x28, 0x7E, 0x6B, 0xFD, 0xC5, 0xF5, 0x1B, 0x62, 0xB9, 0x86, 0x7C, 0xA1, 0x7C, 0xE9, 0x8F, 0xC8, 0xF4, 0xF3, 0x95, 0x5A, 0xAF, 0x0C, 0x21, 0x39, 0xEA, 0x47, 0x5A, 0x1E, 0xBD, 0xBE, 0x7F, 0x1B, 0x0F, 0x31, 0xFB, 0xBD, 0x57, 0xAE, 0xD7, 0xCB, 0x46, 0x83, 0x8B, 0x16, 0x19, 0x74, 0xD9, 0x9E, 0x2D, 0x18, 0xE6, 0xA4, 0x5F, 0x90, 0x90, 0x54, 0xE1, 0x4B, 0x7B, 0x57, 0x76, 0xBD, 0xF4, 0xC0, 0x4D, 0x79, 0x5F, 0x64, 0x6C, 0x0D, 0x2D, 0x02, 0x03, 0x01, 0x00, 0x01, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x04, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, 0x5A, 0x80, 0x5F, 0xD3, 0x3C, 0x93, 0x81, 0xB9, 0x1B, 0xAA, 0x08, 0x1F, 0x47, 0x9C, 0x88,  0xF3, 0x1E, 0xE6, 0x6B, 0xBB, 0x99, 0xE6, 0x23, 0x1A, 0xCB, 0x25, 0x81, 0x54, 0x51, 0x88, 0xDF,  0x9B, 0xC6, 0xBF, 0x60, 0xDB, 0x6C, 0x5D, 0x69, 0xB1, 0x3A, 0xDE, 0x94, 0xEE, 0xD7, 0x6C, 0xF2, 0x2D, 0x63, 0xD3, 0xB3, 0xAB, 0xE6, 0xB5, 0x0A, 0xBF, 0xCE, 0x61, 0xC0, 0xD3, 0x73, 0x9E, 0x80,  0xB5, 0x0C, 0xC0, 0x03, 0x57, 0xA9, 0x56, 0x59, 0x1B, 0xA2, 0x99, 0x03, 0xA6, 0xA3, 0xC4, 0x59, 0xB3, 0xD9, 0x14, 0xA1, 0x34, 0x18, 0xF3, 0x73, 0xB8, 0x54, 0xAA, 0xED, 0x7D, 0x31, 0x3E, 0x23, 0xAD, 0xF1, 0x86, 0xF7, 0xE6, 0xD9, 0x01, 0x0D, 0x68, 0xC6, 0xC5, 0x95, 0x18, 0xD2, 0x89, 0xB7, 0x06, 0x96, 0xC9, 0x11, 0xB9, 0xF0, 0xDA, 0xD9, 0x02, 0x25, 0xC4, 0xB9, 0x72, 0xF8, 0x6D, 0xC5, 0x5B}|VOID*|0x00000003
    5058
    51   ## Indicates the X509 certificate file's size.
     59  ## X509 certificate as Public Key's size.
     60  # @Prompt Pubic Key's size.
    5261  gEfiNetworkPkgTokenSpaceGuid.PcdIpsecUefiCertificateSize|0x251|UINT32|0x00000004
    5362
    54   ## Indicates the Private Key used by IPsec (PEM format).
     63  ## Private Key used by IPsec (PEM format).
     64  # @Prompt Private Key.
    5565  gEfiNetworkPkgTokenSpaceGuid.PcdIpsecUefiCertificateKey|{0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x42, 0x45, 0x47, 0x49, 0x4E, 0x20, 0x52, 0x53, 0x41, 0x20, 0x50,  0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x20, 0x4B, 0x45, 0x59, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x0A, 0x50, 0x72, 0x6F, 0x63, 0x2D, 0x54, 0x79, 0x70, 0x65, 0x3A, 0x20, 0x34, 0x2C, 0x45, 0x4E, 0x43,  0x52, 0x59, 0x50, 0x54, 0x45, 0x44, 0x0A, 0x44, 0x45, 0x4B, 0x2D, 0x49, 0x6E, 0x66, 0x6F, 0x3A,  0x20, 0x44, 0x45, 0x53, 0x2D, 0x45, 0x44, 0x45, 0x33, 0x2D, 0x43, 0x42, 0x43, 0x2C, 0x32, 0x42,  0x31, 0x46, 0x42, 0x41, 0x43, 0x41, 0x38, 0x36, 0x32, 0x36, 0x33, 0x34, 0x41, 0x37, 0x0A, 0x0A,  0x61, 0x52, 0x78, 0x49, 0x58, 0x33, 0x59, 0x4D, 0x68, 0x49, 0x50, 0x41, 0x73, 0x59, 0x79, 0x6F,  0x6A, 0x49, 0x76, 0x46, 0x7A, 0x42, 0x75, 0x6B, 0x74, 0x6B, 0x4A, 0x47, 0x5A, 0x38, 0x4D, 0x64,  0x33, 0x5A, 0x53, 0x73, 0x39, 0x41, 0x2B, 0x52, 0x2B, 0x57, 0x45, 0x59, 0x41, 0x70, 0x34, 0x63,  0x4F, 0x55, 0x43, 0x4A, 0x78, 0x51, 0x2F, 0x66, 0x4A, 0x38, 0x58, 0x4F, 0x45, 0x64, 0x58, 0x38,  0x0A, 0x31, 0x63, 0x4E, 0x66, 0x4B, 0x2B, 0x49, 0x62, 0x76, 0x4B, 0x4D, 0x68, 0x55, 0x67, 0x30,  0x4B, 0x4E, 0x35, 0x38, 0x37, 0x71, 0x66, 0x2F, 0x4C, 0x31, 0x76, 0x57, 0x58, 0x6F, 0x31, 0x74,  0x5A, 0x6B, 0x59, 0x2B, 0x5A, 0x53, 0x4E, 0x63, 0x46, 0x45, 0x41, 0x76, 0x37, 0x43, 0x43, 0x50,  0x51, 0x6B, 0x64, 0x4A, 0x42, 0x48, 0x35, 0x65, 0x6B, 0x35, 0x44, 0x51, 0x2F, 0x37, 0x6D, 0x71,  0x55, 0x0A, 0x6B, 0x76, 0x78, 0x48, 0x53, 0x50, 0x70, 0x34, 0x66, 0x41, 0x71, 0x47, 0x61, 0x68,  0x54, 0x31, 0x75, 0x37, 0x37, 0x56, 0x66, 0x4E, 0x66, 0x31, 0x53, 0x74, 0x61, 0x73, 0x31, 0x6E,  0x4F, 0x67, 0x6A, 0x50, 0x31, 0x41, 0x6C, 0x7A, 0x6E, 0x6B, 0x6A, 0x57, 0x61, 0x72, 0x6A, 0x51,  0x4F, 0x73, 0x48, 0x46, 0x33, 0x41, 0x46, 0x31, 0x62, 0x61, 0x51, 0x4A, 0x50, 0x5A, 0x31, 0x6A,  0x71, 0x4C, 0x0A, 0x61, 0x30, 0x49, 0x45, 0x6E, 0x30, 0x6C, 0x59, 0x6C, 0x78, 0x35, 0x79, 0x4D,  0x6D, 0x78, 0x54, 0x47, 0x57, 0x79, 0x52, 0x35, 0x70, 0x57, 0x51, 0x35, 0x71, 0x66, 0x78, 0x2B,  0x62, 0x37, 0x64, 0x37, 0x75, 0x71, 0x67, 0x47, 0x69, 0x66, 0x36, 0x6A, 0x44, 0x47, 0x4D, 0x37,  0x68, 0x38, 0x43, 0x78, 0x2F, 0x74, 0x67, 0x2B, 0x61, 0x62, 0x45, 0x31, 0x34, 0x30, 0x2F, 0x50,  0x66, 0x6C, 0x33, 0x0A, 0x33, 0x6A, 0x50, 0x6C, 0x52, 0x75, 0x73, 0x57, 0x6F, 0x6F, 0x63, 0x49,  0x41, 0x76, 0x49, 0x74, 0x79, 0x51, 0x6D, 0x39, 0x39, 0x71, 0x74, 0x34, 0x64, 0x6E, 0x74, 0x6E,  0x74, 0x6F, 0x4A, 0x43, 0x6D, 0x4F, 0x53, 0x79, 0x71, 0x67, 0x4D, 0x6E, 0x76, 0x2F, 0x76, 0x2B,  0x51, 0x48, 0x74, 0x79, 0x4D, 0x73, 0x42, 0x64, 0x38, 0x34, 0x78, 0x45, 0x57, 0x46, 0x36, 0x72,  0x58, 0x4D, 0x52, 0x63, 0x0A, 0x53, 0x2B, 0x66, 0x68, 0x54, 0x71, 0x58, 0x74, 0x54, 0x38, 0x44,  0x50, 0x65, 0x70, 0x2F, 0x56, 0x44, 0x66, 0x65, 0x78, 0x6B, 0x41, 0x63, 0x6D, 0x63, 0x75, 0x41,  0x69, 0x6F, 0x2B, 0x79, 0x64, 0x51, 0x75, 0x49, 0x31, 0x32, 0x7A, 0x50, 0x70, 0x45, 0x68, 0x50,  0x45, 0x68, 0x31, 0x44, 0x50, 0x58, 0x73, 0x64, 0x58, 0x67, 0x64, 0x77, 0x39, 0x75, 0x46, 0x47,  0x6D, 0x63, 0x35, 0x68, 0x52, 0x0A, 0x35, 0x31, 0x57, 0x41, 0x31, 0x65, 0x63, 0x44, 0x48, 0x6A,  0x31, 0x58, 0x32, 0x45, 0x72, 0x36, 0x39, 0x59, 0x70, 0x31, 0x50, 0x69, 0x43, 0x37, 0x49, 0x47,  0x79, 0x6F, 0x71, 0x57, 0x43, 0x37, 0x69, 0x2F, 0x71, 0x6D, 0x6D, 0x72, 0x49, 0x66, 0x6F, 0x41,  0x54, 0x74, 0x39, 0x58, 0x34, 0x30, 0x54, 0x56, 0x63, 0x37, 0x42, 0x63, 0x6A, 0x34, 0x63, 0x54,  0x31, 0x78, 0x37, 0x6B, 0x70, 0x4F, 0x0A, 0x4C, 0x71, 0x67, 0x33, 0x6C, 0x50, 0x78, 0x33, 0x2B,  0x4A, 0x63, 0x33, 0x43, 0x67, 0x34, 0x79, 0x5A, 0x54, 0x66, 0x6E, 0x4A, 0x5A, 0x37, 0x48, 0x76,  0x36, 0x64, 0x68, 0x67, 0x45, 0x6D, 0x70, 0x4D, 0x73, 0x74, 0x46, 0x65, 0x35, 0x34, 0x49, 0x53,  0x76, 0x74, 0x38, 0x37, 0x59, 0x4E, 0x77, 0x74, 0x4C, 0x65, 0x6C, 0x34, 0x67, 0x50, 0x4A, 0x79,  0x53, 0x42, 0x30, 0x4B, 0x76, 0x37, 0x69, 0x0A, 0x33, 0x32, 0x74, 0x37, 0x67, 0x4F, 0x30, 0x79,  0x6D, 0x73, 0x62, 0x71, 0x4A, 0x55, 0x75, 0x79, 0x41, 0x68, 0x47, 0x64, 0x33, 0x63, 0x2B, 0x78,  0x4C, 0x46, 0x2F, 0x63, 0x63, 0x4F, 0x57, 0x44, 0x52, 0x34, 0x79, 0x72, 0x30, 0x6A, 0x79, 0x64,  0x74, 0x70, 0x79, 0x69, 0x64, 0x52, 0x45, 0x66, 0x56, 0x46, 0x66, 0x53, 0x6C, 0x39, 0x54, 0x30,  0x6D, 0x53, 0x72, 0x4E, 0x76, 0x43, 0x71, 0x45, 0x0A, 0x52, 0x52, 0x5A, 0x6E, 0x42, 0x56, 0x76,  0x37, 0x50, 0x66, 0x6C, 0x75, 0x72, 0x31, 0x59, 0x35, 0x70, 0x2F, 0x65, 0x78, 0x54, 0x63, 0x56,  0x34, 0x72, 0x4B, 0x52, 0x69, 0x6C, 0x35, 0x58, 0x6A, 0x2F, 0x39, 0x59, 0x56, 0x31, 0x4E, 0x6E,  0x6D, 0x4E, 0x2B, 0x2F, 0x31, 0x31, 0x74, 0x36, 0x58, 0x74, 0x6A, 0x72, 0x75, 0x52, 0x62, 0x33,  0x79, 0x70, 0x38, 0x76, 0x64, 0x6C, 0x61, 0x65, 0x5A, 0x0A, 0x6C, 0x67, 0x45, 0x69, 0x73, 0x30,  0x42, 0x7A, 0x4B, 0x59, 0x39, 0x59, 0x64, 0x58, 0x48, 0x64, 0x46, 0x58, 0x57, 0x59, 0x4F, 0x41,  0x71, 0x50, 0x48, 0x45, 0x65, 0x4B, 0x57, 0x79, 0x61, 0x59, 0x5A, 0x56, 0x79, 0x43, 0x70, 0x51,  0x65, 0x43, 0x53, 0x71, 0x4F, 0x71, 0x48, 0x38, 0x67, 0x42, 0x6B, 0x4F, 0x62, 0x43, 0x69, 0x72,  0x41, 0x6A, 0x65, 0x56, 0x70, 0x35, 0x7A, 0x37, 0x6B, 0x31, 0x0A, 0x64, 0x4F, 0x2F, 0x6D, 0x56,  0x74, 0x49, 0x2B, 0x57, 0x47, 0x30, 0x48, 0x72, 0x37, 0x5A, 0x4C, 0x53, 0x52, 0x78, 0x6F, 0x61,  0x44, 0x47, 0x42, 0x33, 0x4E, 0x35, 0x38, 0x4B, 0x56, 0x45, 0x4F, 0x34, 0x65, 0x46, 0x56, 0x75,  0x6E, 0x59, 0x77, 0x51, 0x42, 0x54, 0x7A, 0x4F, 0x65, 0x57, 0x39, 0x6C, 0x4B, 0x79, 0x49, 0x38,  0x67, 0x4D, 0x45, 0x57, 0x6C, 0x62, 0x4B, 0x72, 0x41, 0x45, 0x49, 0x0A, 0x46, 0x4B, 0x38, 0x7A,  0x58, 0x6F, 0x44, 0x74, 0x39, 0x6A, 0x7A, 0x54, 0x37, 0x67, 0x68, 0x6A, 0x79, 0x45, 0x54, 0x67,  0x44, 0x6C, 0x69, 0x50, 0x53, 0x49, 0x46, 0x6A, 0x79, 0x31, 0x64, 0x6B, 0x6A, 0x6D, 0x68, 0x53,  0x78, 0x79, 0x6A, 0x67, 0x62, 0x71, 0x45, 0x3D, 0x0A, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x45, 0x4E,  0x44, 0x20, 0x52, 0x53, 0x41, 0x20, 0x50, 0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x20, 0x4B, 0x45,  0x59, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x0A}|VOID*|0x00000005
    5666
    57   ## Indicates the private key's size.
     67  ## Private Key's size.
     68  # @Prompt Private Key's size.
    5869  gEfiNetworkPkgTokenSpaceGuid.PcdIpsecUefiCertificateKeySize|0x3d5|UINT32|0x00000006
     70
     71[UserExtensions.TianoCore."ExtraFiles"]
     72  NetworkPkgExtra.uni
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/NetworkPkg.dsc

    r48674 r58459  
    11## @file
    2 # UEFI 2.2 Network Module Package for All Architectures
     2# UEFI 2.4 Network Module Package for All Architectures
    33#
    4 # Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4# Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55#
    66#    This program and the accompanying materials
     
    1717  PLATFORM_NAME                  = NetworkPkg
    1818  PLATFORM_GUID                  = 3FD34E9B-E90C-44e1-B510-1F632A509F10
    19   PLATFORM_VERSION               = 0.93
     19  PLATFORM_VERSION               = 0.95
    2020  DSC_SPECIFICATION              = 0x00010005
    2121  OUTPUT_DIRECTORY               = Build/NetworkPkg
     
    8686
    8787[Components]
    88   NetworkPkg/IpSecDxe/IpSecDxe.inf
    8988  NetworkPkg/Ip6Dxe/Ip6Dxe.inf
    9089  NetworkPkg/TcpDxe/TcpDxe.inf
     
    9392  NetworkPkg/Mtftp6Dxe/Mtftp6Dxe.inf
    9493
     94  NetworkPkg/Application/IfConfig6/IfConfig6.inf
     95  NetworkPkg/Application/IpsecConfig/IpSecConfig.inf
     96  NetworkPkg/Application/VConfig/VConfig.inf
     97
    9598[Components.IA32, Components.X64, Components.IPF]
     99  NetworkPkg/IpSecDxe/IpSecDxe.inf
    96100  NetworkPkg/IScsiDxe/IScsiDxe.inf
    97101  NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf
    98102  NetworkPkg/Application/Ping6/Ping6.inf
    99   NetworkPkg/Application/IfConfig6/IfConfig6.inf
    100   NetworkPkg/Application/IpsecConfig/IpSecConfig.inf
    101   NetworkPkg/Application/VConfig/VConfig.inf
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/TcpDxe/ComponentName.c

    r48674 r58459  
    33  EFI_COMPONENT_NAME2_PROTOCOL.
    44
    5   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     5  Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
    66
    77  This program and the accompanying materials
     
    170170  }
    171171};
     172
     173GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE        *gTcpControllerNameTable = NULL;
    172174
    173175/**
     
    226228
    227229/**
     230  Update the component name for the Tcp4 child handle.
     231
     232  @param  Tcp4[in]                   A pointer to the EFI_TCP4_PROTOCOL.
     233
     234 
     235  @retval EFI_SUCCESS                Update the ControllerNameTable of this instance successfully.
     236  @retval EFI_INVALID_PARAMETER      The input parameter is invalid.
     237 
     238**/
     239EFI_STATUS
     240UpdateTcp4Name (
     241  IN    EFI_TCP4_PROTOCOL             *Tcp4
     242  )
     243{
     244  EFI_STATUS                       Status;
     245  CHAR16                           HandleName[80];
     246  EFI_TCP4_CONFIG_DATA             Tcp4ConfigData;
     247
     248  if (Tcp4 == NULL) {
     249    return EFI_INVALID_PARAMETER;
     250  }
     251
     252  //
     253  // Format the child name into the string buffer as:
     254  // TCPv4 (SrcPort=59, DestPort=60, ActiveFlag=TRUE)
     255  //
     256  ZeroMem (&Tcp4ConfigData, sizeof (Tcp4ConfigData));
     257  Status = Tcp4->GetModeData (Tcp4, NULL, &Tcp4ConfigData, NULL, NULL, NULL);
     258  if (!EFI_ERROR (Status)) {
     259    UnicodeSPrint (HandleName, sizeof (HandleName),
     260      L"TCPv4 (SrcPort=%d, DestPort=%d, ActiveFlag=%s)",
     261      Tcp4ConfigData.AccessPoint.StationPort,
     262      Tcp4ConfigData.AccessPoint.RemotePort,
     263      (Tcp4ConfigData.AccessPoint.ActiveFlag ? L"TRUE" : L"FALSE")
     264      );
     265  } else if (Status == EFI_NOT_STARTED) {
     266    UnicodeSPrint (
     267      HandleName,
     268      sizeof (HandleName),
     269      L"TCPv4 (Not started)"
     270      );
     271  } else {
     272    return Status;
     273  }
     274
     275  if (gTcpControllerNameTable != NULL) {
     276    FreeUnicodeStringTable (gTcpControllerNameTable);
     277    gTcpControllerNameTable = NULL;
     278  }
     279 
     280  Status = AddUnicodeString2 (
     281             "eng",
     282             gTcpComponentName.SupportedLanguages,
     283             &gTcpControllerNameTable,
     284             HandleName,
     285             TRUE
     286             );
     287  if (EFI_ERROR (Status)) {
     288    return Status;
     289  }
     290 
     291  return AddUnicodeString2 (
     292           "en",
     293           gTcpComponentName2.SupportedLanguages,
     294           &gTcpControllerNameTable,
     295           HandleName,
     296           FALSE
     297           );
     298}
     299
     300/**
     301  Update the component name for the Tcp6 child handle.
     302
     303  @param  Tcp6[in]                   A pointer to the EFI_TCP6_PROTOCOL.
     304
     305 
     306  @retval EFI_SUCCESS                Update the ControllerNameTable of this instance successfully.
     307  @retval EFI_INVALID_PARAMETER      The input parameter is invalid.
     308 
     309**/
     310EFI_STATUS
     311UpdateTcp6Name (
     312  IN    EFI_TCP6_PROTOCOL             *Tcp6
     313  )
     314{
     315  EFI_STATUS                       Status;
     316  CHAR16                           HandleName[80];
     317  EFI_TCP6_CONFIG_DATA             Tcp6ConfigData;
     318
     319  if (Tcp6 == NULL) {
     320    return EFI_INVALID_PARAMETER;
     321  }
     322
     323  //
     324  // Format the child name into the string buffer.
     325  //
     326  ZeroMem (&Tcp6ConfigData, sizeof (Tcp6ConfigData));
     327  Status = Tcp6->GetModeData (Tcp6, NULL, &Tcp6ConfigData, NULL, NULL, NULL);
     328  if (!EFI_ERROR (Status)) {
     329    UnicodeSPrint (HandleName, sizeof (HandleName),
     330      L"TCPv6(SrcPort=%d, DestPort=%d, ActiveFlag=%d)",
     331      Tcp6ConfigData.AccessPoint.StationPort,
     332      Tcp6ConfigData.AccessPoint.RemotePort,
     333      Tcp6ConfigData.AccessPoint.ActiveFlag
     334      );
     335  } else if (Status == EFI_NOT_STARTED) {
     336    UnicodeSPrint (HandleName, sizeof (HandleName), L"TCPv6(Not started)");
     337  } else {
     338    return Status;
     339  }
     340
     341
     342  if (gTcpControllerNameTable != NULL) {
     343    FreeUnicodeStringTable (gTcpControllerNameTable);
     344    gTcpControllerNameTable = NULL;
     345  }
     346 
     347  Status = AddUnicodeString2 (
     348             "eng",
     349             gTcpComponentName.SupportedLanguages,
     350             &gTcpControllerNameTable,
     351             HandleName,
     352             TRUE
     353             );
     354  if (EFI_ERROR (Status)) {
     355    return Status;
     356  }
     357 
     358  return AddUnicodeString2 (
     359           "en",
     360           gTcpComponentName2.SupportedLanguages,
     361           &gTcpControllerNameTable,
     362           HandleName,
     363           FALSE
     364           );
     365}
     366
     367/**
    228368  Retrieves a Unicode string that is the user-readable name of the controller
    229369  that is being managed by a driver.
     
    301441  )
    302442{
    303   return EFI_UNSUPPORTED;
     443  EFI_STATUS                    Status;
     444  EFI_TCP4_PROTOCOL             *Tcp4;
     445  EFI_TCP6_PROTOCOL             *Tcp6;
     446
     447  //
     448  // Only provide names for child handles.
     449  //
     450  if (ChildHandle == NULL) {
     451    return EFI_UNSUPPORTED;
     452  }
     453
     454  //
     455  // Make sure this driver produced ChildHandle
     456  //
     457  Status = EfiTestChildHandle (
     458             ControllerHandle,
     459             ChildHandle,
     460             &gEfiIp6ProtocolGuid
     461             );
     462  if (!EFI_ERROR (Status)) {
     463    //
     464    // Retrieve an instance of a produced protocol from ChildHandle
     465    //
     466    Status = gBS->OpenProtocol (
     467                    ChildHandle,
     468                    &gEfiTcp6ProtocolGuid,
     469                   (VOID **)&Tcp6,
     470                    NULL,
     471                    NULL,
     472                    EFI_OPEN_PROTOCOL_GET_PROTOCOL
     473                    );
     474    if (EFI_ERROR (Status)) {
     475      return Status;
     476    }
     477
     478    //
     479    // Update the component name for this child handle.
     480    //
     481    Status = UpdateTcp6Name (Tcp6);
     482    if (EFI_ERROR (Status)) {
     483      return Status;
     484    }
     485  }
     486
     487  //
     488  // Make sure this driver is currently managing ControllHandle
     489  //
     490  Status = EfiTestChildHandle (
     491             ControllerHandle,
     492             ChildHandle,
     493             &gEfiIp4ProtocolGuid
     494             );
     495  if (!EFI_ERROR (Status)) {
     496    //
     497    // Retrieve an instance of a produced protocol from ChildHandle
     498    //
     499    Status = gBS->OpenProtocol (
     500               ChildHandle,
     501               &gEfiTcp4ProtocolGuid,
     502              (VOID **)&Tcp4,
     503               NULL,
     504               NULL,
     505               EFI_OPEN_PROTOCOL_GET_PROTOCOL
     506               );
     507    if (EFI_ERROR (Status)) {
     508      return Status;
     509    }
     510
     511    //
     512    // Update the component name for this child handle.
     513    //
     514    Status = UpdateTcp4Name (Tcp4);
     515    if (EFI_ERROR (Status)) {
     516      return Status;
     517    }
     518  }
     519
     520  return LookupUnicodeString2 (
     521           Language,
     522           This->SupportedLanguages,
     523           gTcpControllerNameTable,
     524           ControllerName,
     525           (BOOLEAN)(This == &gTcpComponentName)
     526           );
    304527}
     528
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/TcpDxe/SockImpl.c

    r48674 r58459  
    22  Implementation of the Socket.
    33
    4   Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    788788  }
    789789  //
    790   // Destory the RcvBuffer Queue and SendBuffer Queue
     790  // Destroy the RcvBuffer Queue and SendBuffer Queue
    791791  //
    792792  NetbufQueFree (Sock->RcvBuffer.DataQueue);
     
    803803    DEBUG (
    804804      (EFI_D_WARN,
    805       "SockDestory: Delete a unaccepted socket from parent now conncnt is %d\n",
     805      "SockDestroy: Delete a unaccepted socket from parent now conncnt is %d\n",
    806806      Sock->Parent->ConnCnt)
    807807      );
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/TcpDxe/SockInterface.c

    r48674 r58459  
    22  Interface function of the Socket.
    33
    4   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    130130
    131131/**
    132   Destory the socket Sock and its associated protocol control block.
     132  Destroy the socket Sock and its associated protocol control block.
    133133
    134134  @param[in, out]  Sock                 The socket to be destroyed.
     
    147147  ASSERT ((Sock != NULL) && (Sock->ProtoHandler != NULL));
    148148
    149   if (Sock->IsDestroyed) {
     149  if (Sock->InDestroy) {
    150150    return EFI_SUCCESS;
    151151  }
    152152
    153   Sock->IsDestroyed = TRUE;
     153  Sock->InDestroy = TRUE;
    154154
    155155  Status            = EfiAcquireLockOrFail (&(Sock->Lock));
     
    178178      );
    179179
    180     Sock->IsDestroyed = FALSE;
     180    Sock->InDestroy = FALSE;
    181181  } else if (SOCK_IS_CONFIGURED (Sock)) {
    182182
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/TcpDxe/Socket.h

    r48674 r58459  
    22  Common head file for TCP socket.
    33
    4   Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    478478  SOCK_BUFFER               RcvBuffer;      ///< Receive buffer of received data
    479479  EFI_STATUS                SockError;      ///< The error returned by low layer protocol
    480   BOOLEAN                   IsDestroyed;
     480  BOOLEAN                   InDestroy;
    481481
    482482  //
     
    697697
    698698/**
    699   Destory the socket Sock and its associated protocol control block.
     699  Destroy the socket Sock and its associated protocol control block.
    700700
    701701  @param[in, out]  Sock                 The socket to be destroyed.
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/TcpDxe/TcpDispatcher.c

    r48674 r58459  
    22  The implementation of a dispatch routine for processing TCP requests.
    33
    4   Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    305305{
    306306  SOCKET                    *Sock;
    307   TCP_PROTO_DATA            *TcpProto;
    308307
    309308  IpIoConfigIp (Tcb->IpInfo, NULL);
    310309
    311310  Sock     = Tcb->Sk;
    312   TcpProto = (TCP_PROTO_DATA *) Sock->ProtoReserved;
    313311
    314312  if (SOCK_IS_CONFIGURED (Sock)) {
     
    328326      Sock->DevicePath = NULL;
    329327    }
    330 
    331     TcpSetVariableData (TcpProto->TcpService);
    332328  }
    333329
     
    335331  NetbufFreeList (&Tcb->RcvQue);
    336332  Tcb->State = TCP_CLOSED;
     333  Tcb->RemoteIpZero = FALSE;
    337334}
    338335
     
    354351  TCP_PROTO_DATA  *ProtoData;
    355352  IP_IO           *IpIo;
    356 
     353  EFI_STATUS      Status;
     354  VOID            *Ip;
     355  EFI_GUID        *IpProtocolGuid;
     356
     357  if (Sk->IpVersion == IP_VERSION_4) {
     358    IpProtocolGuid = &gEfiIp4ProtocolGuid;
     359  } else {
     360    IpProtocolGuid = &gEfiIp6ProtocolGuid;
     361  }
     362 
    357363  Tcb = AllocateZeroPool (sizeof (TCP_CB));
    358364
     
    377383  }
    378384
     385  //
     386  // Open the new created IP instance BY_CHILD.
     387  //
     388  Status = gBS->OpenProtocol (
     389                  Tcb->IpInfo->ChildHandle,
     390                  IpProtocolGuid,
     391                  &Ip,
     392                  IpIo->Image,
     393                  Sk->SockHandle,
     394                  EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
     395                  );
     396  if (EFI_ERROR (Status)) {
     397    IpIoRemoveIp (IpIo, Tcb->IpInfo);
     398    return Status;
     399  }
     400 
    379401  InitializeListHead (&Tcb->List);
    380402  InitializeListHead (&Tcb->SndQue);
     
    401423  TCP_PROTO_DATA   *ProtoData;
    402424  TCP_CB           *Tcb;
    403 
     425  EFI_GUID         *IpProtocolGuid;
     426
     427  if (Sk->IpVersion == IP_VERSION_4) {
     428    IpProtocolGuid = &gEfiIp4ProtocolGuid;
     429  } else {
     430    IpProtocolGuid = &gEfiIp6ProtocolGuid;
     431  }
     432 
    404433  ProtoData = (TCP_PROTO_DATA *) Sk->ProtoReserved;
    405434  Tcb       = ProtoData->TcpPcb;
     
    409438  TcpFlushPcb (Tcb);
    410439
     440  //
     441  // Close the IP protocol.
     442  //
     443  gBS->CloseProtocol (
     444         Tcb->IpInfo->ChildHandle,
     445         IpProtocolGuid,
     446         ProtoData->TcpService->IpIo->Image,
     447         Sk->SockHandle
     448         );
     449 
    411450  IpIoRemoveIp (ProtoData->TcpService->IpIo, Tcb->IpInfo);
    412451
     
    712751  if (Sk->IpVersion == IP_VERSION_6) {
    713752    Tcb->Tick          = TCP6_REFRESH_NEIGHBOR_TICK;
     753
     754    if (NetIp6IsUnspecifiedAddr (&Tcb->RemoteEnd.Ip.v6)) {
     755      Tcb->RemoteIpZero = TRUE;
     756    }
    714757  }
    715758
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/TcpDxe/TcpDriver.c

    r48674 r58459  
    22  The driver binding and service binding protocol for the TCP driver.
    33
    4   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    6767};
    6868
    69 EFI_DRIVER_BINDING_PROTOCOL   gTcpDriverBinding = {
    70   TcpDriverBindingSupported,
    71   TcpDriverBindingStart,
    72   TcpDriverBindingStop,
     69EFI_DRIVER_BINDING_PROTOCOL   gTcp4DriverBinding = {
     70  Tcp4DriverBindingSupported,
     71  Tcp4DriverBindingStart,
     72  Tcp4DriverBindingStop,
     73  0xa,
     74  NULL,
     75  NULL
     76};
     77
     78EFI_DRIVER_BINDING_PROTOCOL   gTcp6DriverBinding = {
     79  Tcp6DriverBindingSupported,
     80  Tcp6DriverBindingStart,
     81  Tcp6DriverBindingStop,
    7382  0xa,
    7483  NULL,
     
    173182             ImageHandle,
    174183             SystemTable,
    175              &gTcpDriverBinding,
     184             &gTcp4DriverBinding,
    176185             ImageHandle,
    177186             &gTcpComponentName,
     
    179188             );
    180189  if (EFI_ERROR (Status)) {
     190    return Status;
     191  }
     192
     193  //
     194  // Install the TCP Driver Binding Protocol
     195  //
     196  Status = EfiLibInstallDriverBindingComponentName2 (
     197             ImageHandle,
     198             SystemTable,
     199             &gTcp6DriverBinding,
     200             NULL,
     201             &gTcpComponentName,
     202             &gTcpComponentName2
     203             );
     204  if (EFI_ERROR (Status)) {
     205    gBS->UninstallMultipleProtocolInterfaces (
     206           ImageHandle,
     207           &gEfiDriverBindingProtocolGuid,
     208           &gTcp4DriverBinding,
     209           &gEfiComponentName2ProtocolGuid,
     210           &gTcpComponentName2,
     211           &gEfiComponentNameProtocolGuid,
     212           &gTcpComponentName,
     213           NULL
     214           );
    181215    return Status;
    182216  }
     
    316350  }
    317351
    318   TcpSetVariableData (TcpServiceData);
    319 
    320352  return EFI_SUCCESS;
    321353
     
    324356  if (TcpServiceData->IpIo != NULL) {
    325357    IpIoDestroy (TcpServiceData->IpIo);
     358    TcpServiceData->IpIo = NULL;
    326359  }
    327360
     
    329362
    330363  return Status;
     364}
     365
     366/**
     367  Callback function which provided by user to remove one node in NetDestroyLinkList process.
     368 
     369  @param[in]    Entry           The entry to be removed.
     370  @param[in]    Context         Pointer to the callback context corresponds to the Context in NetDestroyLinkList.
     371
     372  @retval EFI_SUCCESS           The entry has been removed successfully.
     373  @retval Others                Fail to remove the entry.
     374
     375**/
     376EFI_STATUS
     377EFIAPI
     378TcpDestroyChildEntryInHandleBuffer (
     379  IN LIST_ENTRY         *Entry,
     380  IN VOID               *Context
     381  )
     382{
     383  SOCKET                        *Sock;
     384  EFI_SERVICE_BINDING_PROTOCOL  *ServiceBinding;
     385  UINTN                         NumberOfChildren;
     386  EFI_HANDLE                    *ChildHandleBuffer;
     387
     388  if (Entry == NULL || Context == NULL) {
     389    return EFI_INVALID_PARAMETER;
     390  }
     391
     392  Sock = NET_LIST_USER_STRUCT_S (Entry, SOCKET, Link, SOCK_SIGNATURE);
     393  ServiceBinding    = ((TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding;
     394  NumberOfChildren  = ((TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren;
     395  ChildHandleBuffer = ((TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer;
     396
     397  if (!NetIsInHandleBuffer (Sock->SockHandle, NumberOfChildren, ChildHandleBuffer)) {
     398    return EFI_SUCCESS;
     399  }
     400
     401  return ServiceBinding->DestroyChild (ServiceBinding, Sock->SockHandle);
    331402}
    332403
     
    337408  @param[in]  Controller         Controller handle of device to bind driver to.
    338409  @param[in]  ImageHandle        The TCP driver's image handle.
    339   @param[in]  NumberOfChildren    Number of Handles in ChildHandleBuffer. If number
     410  @param[in]  NumberOfChildren   Number of Handles in ChildHandleBuffer. If number
    340411                                 of children is zero stop the entire bus driver.
     412  @param[in]  ChildHandleBuffer  An array of child handles to be freed. May be NULL
     413                                 if NumberOfChildren is 0. 
    341414  @param[in]  IpVersion          IP_VERSION_4 or IP_VERSION_6
    342415
     
    350423  IN EFI_HANDLE  ImageHandle,
    351424  IN UINTN       NumberOfChildren,
     425  IN EFI_HANDLE  *ChildHandleBuffer, OPTIONAL
    352426  IN UINT8       IpVersion
    353427  )
     
    359433  TCP_SERVICE_DATA              *TcpServiceData;
    360434  EFI_STATUS                    Status;
    361   SOCKET                        *Sock;
     435  LIST_ENTRY                    *List;
     436  TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT  Context;
    362437
    363438  ASSERT ((IpVersion == IP_VERSION_4) || (IpVersion == IP_VERSION_6));
     
    373448  NicHandle = NetLibGetNicHandle (Controller, IpProtocolGuid);
    374449  if (NicHandle == NULL) {
    375     return EFI_NOT_FOUND;
     450    return EFI_SUCCESS;
    376451  }
    377452
     
    390465  TcpServiceData = TCP_SERVICE_FROM_THIS (ServiceBinding);
    391466
    392   if (NumberOfChildren == 0) {
     467  if (NumberOfChildren != 0) {
     468    List = &TcpServiceData->SocketList;
     469    Context.ServiceBinding = ServiceBinding;
     470    Context.NumberOfChildren = NumberOfChildren;
     471    Context.ChildHandleBuffer = ChildHandleBuffer;
     472    Status = NetDestroyLinkList (
     473               List,
     474               TcpDestroyChildEntryInHandleBuffer,
     475               &Context,
     476               NULL
     477               );
     478  } else if (IsListEmpty (&TcpServiceData->SocketList)) {
    393479    //
    394480    // Uninstall TCP servicebinding protocol
     
    405491    //
    406492    IpIoDestroy (TcpServiceData->IpIo);
     493    TcpServiceData->IpIo = NULL;
    407494
    408495    //
     
    412499
    413500    //
    414     // Clear the variable.
    415     //
    416     TcpClearVariableData (TcpServiceData);
    417 
    418     //
    419501    // Release the TCP service data
    420502    //
    421503    FreePool (TcpServiceData);
    422   } else {
    423 
    424     while (!IsListEmpty (&TcpServiceData->SocketList)) {
    425       Sock = NET_LIST_HEAD (&TcpServiceData->SocketList, SOCKET, Link);
    426 
    427       ServiceBinding->DestroyChild (ServiceBinding, Sock->SockHandle);
    428     }
    429   }
    430 
    431   return EFI_SUCCESS;
     504
     505    Status = EFI_SUCCESS;
     506  }
     507
     508  return Status;
    432509}
    433510
     
    447524EFI_STATUS
    448525EFIAPI
    449 TcpDriverBindingSupported (
     526Tcp4DriverBindingSupported (
    450527  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
    451528  IN EFI_HANDLE                   ControllerHandle,
     
    454531{
    455532  EFI_STATUS  Status;
    456   BOOLEAN     IsTcp4Started;
    457533
    458534  //
     
    467543                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
    468544                  );
    469   if (EFI_ERROR (Status)) {
    470     //
    471     // Test for the Ip4ServiceBinding Protocol
    472     //
    473     Status = gBS->OpenProtocol (
    474                     ControllerHandle,
    475                     &gEfiIp4ServiceBindingProtocolGuid,
    476                     NULL,
    477                     This->DriverBindingHandle,
    478                     ControllerHandle,
    479                     EFI_OPEN_PROTOCOL_TEST_PROTOCOL
    480                     );
    481     if (!EFI_ERROR (Status)) {
    482       return EFI_SUCCESS;
    483     }
    484 
    485     IsTcp4Started = FALSE;
    486   } else {
    487     IsTcp4Started = TRUE;
    488   }
    489 
    490   //
    491   // Check the Tcp6ServiceBinding Protocol
     545  if (!EFI_ERROR (Status)) {
     546    return EFI_ALREADY_STARTED;
     547  }
     548 
     549  //
     550  // Test for the Ip4ServiceBinding Protocol
     551  //
     552  Status = gBS->OpenProtocol (
     553                  ControllerHandle,
     554                  &gEfiIp4ServiceBindingProtocolGuid,
     555                  NULL,
     556                  This->DriverBindingHandle,
     557                  ControllerHandle,
     558                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
     559                  );
     560  return Status;
     561}
     562
     563/**
     564  Start this driver on ControllerHandle.
     565
     566  @param[in]  This                   Protocol instance pointer.
     567  @param[in]  ControllerHandle       Handle of device to bind driver to.
     568  @param[in]  RemainingDevicePath    Optional parameter use to pick a specific child
     569                                     device to start.
     570
     571  @retval EFI_SUCCESS            The driver is added to ControllerHandle.
     572  @retval EFI_OUT_OF_RESOURCES   There are not enough resources to start the
     573                                 driver.
     574  @retval other                  The driver cannot be added to ControllerHandle.
     575
     576**/
     577EFI_STATUS
     578EFIAPI
     579Tcp4DriverBindingStart (
     580  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     581  IN EFI_HANDLE                   ControllerHandle,
     582  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
     583  )
     584{
     585  EFI_STATUS  Status;
     586
     587  Status = TcpCreateService (ControllerHandle, This->DriverBindingHandle, IP_VERSION_4);
     588  if ((Status == EFI_ALREADY_STARTED) || (Status == EFI_UNSUPPORTED)) {
     589    Status = EFI_SUCCESS;
     590  }
     591
     592  return Status;
     593}
     594
     595/**
     596  Stop this driver on ControllerHandle.
     597
     598  @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
     599  @param[in]  ControllerHandle  A handle to the device being stopped. The handle must
     600                                support a bus specific I/O protocol for the driver
     601                                to use to stop the device.
     602  @param[in]  NumberOfChildren  The number of child device handles in ChildHandleBuffer.
     603  @param[in]  ChildHandleBuffer An array of child handles to be freed. May be NULL
     604                                if NumberOfChildren is 0.
     605
     606  @retval EFI_SUCCESS           The device was stopped.
     607  @retval EFI_DEVICE_ERROR      The device could not be stopped due to a device error.
     608
     609**/
     610EFI_STATUS
     611EFIAPI
     612Tcp4DriverBindingStop (
     613  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,
     614  IN  EFI_HANDLE                   ControllerHandle,
     615  IN  UINTN                        NumberOfChildren,
     616  IN  EFI_HANDLE                   *ChildHandleBuffer OPTIONAL
     617  )
     618{
     619  return TcpDestroyService (
     620           ControllerHandle,
     621           This->DriverBindingHandle,
     622           NumberOfChildren,
     623           ChildHandleBuffer,
     624           IP_VERSION_4
     625           );
     626}
     627
     628/**
     629  Test to see if this driver supports ControllerHandle.
     630
     631  @param[in]  This                Protocol instance pointer.
     632  @param[in]  ControllerHandle    Handle of device to test.
     633  @param[in]  RemainingDevicePath Optional parameter use to pick a specific
     634                                  child device to start.
     635
     636  @retval EFI_SUCCESS             This driver supports this device.
     637  @retval EFI_ALREADY_STARTED     This driver is already running on this device.
     638  @retval other                   This driver does not support this device.
     639
     640**/
     641EFI_STATUS
     642EFIAPI
     643Tcp6DriverBindingSupported (
     644  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     645  IN EFI_HANDLE                   ControllerHandle,
     646  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
     647  )
     648{
     649  EFI_STATUS  Status;
     650
     651  //
     652  // Test for the Tcp6ServiceBinding Protocol
    492653  //
    493654  Status = gBS->OpenProtocol (
     
    499660                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
    500661                  );
    501   if (EFI_ERROR (Status)) {
    502     //
    503     // Test for the Ip6ServiceBinding Protocol
    504     //
    505     Status = gBS->OpenProtocol (
    506                     ControllerHandle,
    507                     &gEfiIp6ServiceBindingProtocolGuid,
    508                     NULL,
    509                     This->DriverBindingHandle,
    510                     ControllerHandle,
    511                     EFI_OPEN_PROTOCOL_TEST_PROTOCOL
    512                     );
    513     if (!EFI_ERROR (Status)) {
    514       return EFI_SUCCESS;
    515     }
    516   } else if (IsTcp4Started) {
     662  if (!EFI_ERROR (Status)) {
    517663    return EFI_ALREADY_STARTED;
    518664  }
    519 
    520   return EFI_UNSUPPORTED;
     665 
     666  //
     667  // Test for the Ip6ServiceBinding Protocol
     668  //
     669  Status = gBS->OpenProtocol (
     670                  ControllerHandle,
     671                  &gEfiIp6ServiceBindingProtocolGuid,
     672                  NULL,
     673                  This->DriverBindingHandle,
     674                  ControllerHandle,
     675                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
     676                  );
     677  return Status;
    521678}
    522679
     
    537694EFI_STATUS
    538695EFIAPI
    539 TcpDriverBindingStart (
     696Tcp6DriverBindingStart (
    540697  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
    541698  IN EFI_HANDLE                   ControllerHandle,
     
    543700  )
    544701{
    545   EFI_STATUS  Tcp4Status;
    546   EFI_STATUS  Tcp6Status;
    547 
    548   Tcp4Status = TcpCreateService (ControllerHandle, This->DriverBindingHandle, IP_VERSION_4);
    549   if ((Tcp4Status == EFI_ALREADY_STARTED) || (Tcp4Status == EFI_UNSUPPORTED)) {
    550     Tcp4Status = EFI_SUCCESS;
    551   }
    552 
    553   Tcp6Status = TcpCreateService (ControllerHandle, This->DriverBindingHandle, IP_VERSION_6);
    554   if ((Tcp6Status == EFI_ALREADY_STARTED) || (Tcp6Status == EFI_UNSUPPORTED)) {
    555     Tcp6Status = EFI_SUCCESS;
    556   }
    557 
    558   if (!EFI_ERROR (Tcp4Status) || !EFI_ERROR (Tcp6Status)) {
    559     return EFI_SUCCESS;
    560   } else if (EFI_ERROR (Tcp4Status)) {
    561     return Tcp4Status;
    562   } else {
    563     return Tcp6Status;
    564   }
     702  EFI_STATUS  Status;
     703
     704  Status = TcpCreateService (ControllerHandle, This->DriverBindingHandle, IP_VERSION_6);
     705  if ((Status == EFI_ALREADY_STARTED) || (Status == EFI_UNSUPPORTED)) {
     706    Status = EFI_SUCCESS;
     707  }
     708
     709  return Status;
    565710}
    566711
     
    582727EFI_STATUS
    583728EFIAPI
    584 TcpDriverBindingStop (
     729Tcp6DriverBindingStop (
    585730  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,
    586731  IN  EFI_HANDLE                   ControllerHandle,
     
    589734  )
    590735{
    591   EFI_STATUS  Tcp4Status;
    592   EFI_STATUS  Tcp6Status;
    593 
    594   Tcp4Status = TcpDestroyService (
    595                  ControllerHandle,
    596                  This->DriverBindingHandle,
    597                  NumberOfChildren,
    598                  IP_VERSION_4
    599                  );
    600 
    601   Tcp6Status = TcpDestroyService (
    602                  ControllerHandle,
    603                  This->DriverBindingHandle,
    604                  NumberOfChildren,
    605                  IP_VERSION_6
    606                  );
    607 
    608   if (EFI_ERROR (Tcp4Status) && EFI_ERROR (Tcp6Status)) {
    609     return EFI_DEVICE_ERROR;
    610   } else {
    611     return EFI_SUCCESS;
    612   }
     736  return TcpDestroyService (
     737           ControllerHandle,
     738           This->DriverBindingHandle,
     739           NumberOfChildren,
     740           ChildHandleBuffer,
     741           IP_VERSION_6
     742           );
    613743}
    614744
     
    666796                  TcpServiceData->DriverBindingHandle,
    667797                  This->SockHandle,
    668                   EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
     798                  EFI_OPEN_PROTOCOL_GET_PROTOCOL
    669799                  );
    670800  if (EFI_ERROR (Status)) {
     
    715845
    716846  //
    717   // Close the device path protocol
    718   //
    719   gBS->CloseProtocol (
    720          TcpServiceData->ControllerHandle,
    721          &gEfiDevicePathProtocolGuid,
    722          TcpServiceData->DriverBindingHandle,
    723          This->SockHandle
    724          );
    725 
    726   //
    727847  // Close the IP protocol.
    728848  //
     
    840960  VOID        *Tcp;
    841961  SOCKET      *Sock;
    842   EFI_TPL     OldTpl;
    843962
    844963  if (NULL == This || NULL == ChildHandle) {
    845964    return EFI_INVALID_PARAMETER;
    846965  }
    847 
    848   OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
    849966
    850967  //
     
    855972                  &gEfiTcp4ProtocolGuid,
    856973                  &Tcp,
    857                   gTcpDriverBinding.DriverBindingHandle,
     974                  gTcp4DriverBinding.DriverBindingHandle,
    858975                  ChildHandle,
    859976                  EFI_OPEN_PROTOCOL_GET_PROTOCOL
     
    867984                    &gEfiTcp6ProtocolGuid,
    868985                    &Tcp,
    869                     gTcpDriverBinding.DriverBindingHandle,
     986                    gTcp6DriverBinding.DriverBindingHandle,
    870987                    ChildHandle,
    871988                    EFI_OPEN_PROTOCOL_GET_PROTOCOL
     
    8861003  }
    8871004
    888   gBS->RestoreTPL (OldTpl);
    889 
    8901005  return Status;
    8911006}
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/TcpDxe/TcpDriver.h

    r48674 r58459  
    22  The prototype of driver binding and service binding protocol for TCP driver.
    33
    4   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    3434  IP_IO                         *IpIo;
    3535  EFI_SERVICE_BINDING_PROTOCOL  ServiceBinding;
    36   CHAR16                        *MacString;
    3736  LIST_ENTRY                    SocketList;
    3837} TCP_SERVICE_DATA;
     
    9190EFI_STATUS
    9291EFIAPI
    93 TcpDriverBindingSupported (
     92Tcp4DriverBindingSupported (
    9493  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
    9594  IN EFI_HANDLE                   ControllerHandle,
     
    113112EFI_STATUS
    114113EFIAPI
    115 TcpDriverBindingStart (
     114Tcp4DriverBindingStart (
    116115  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
    117116  IN EFI_HANDLE                   ControllerHandle,
     
    136135EFI_STATUS
    137136EFIAPI
    138 TcpDriverBindingStop (
     137Tcp4DriverBindingStop (
     138  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,
     139  IN  EFI_HANDLE                   ControllerHandle,
     140  IN  UINTN                        NumberOfChildren,
     141  IN  EFI_HANDLE                   *ChildHandleBuffer OPTIONAL
     142  );
     143
     144/**
     145  Test to see if this driver supports ControllerHandle.
     146
     147  @param[in]  This                Protocol instance pointer.
     148  @param[in]  ControllerHandle    Handle of the device to test.
     149  @param[in]  RemainingDevicePath Optional parameter use to pick a specific
     150                                  child device to start.
     151
     152  @retval EFI_SUCCESS             This driver supports this device.
     153  @retval EFI_ALREADY_STARTED     This driver is already running on this device.
     154  @retval other                   This driver does not support this device.
     155
     156**/
     157EFI_STATUS
     158EFIAPI
     159Tcp6DriverBindingSupported (
     160  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     161  IN EFI_HANDLE                   ControllerHandle,
     162  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
     163  );
     164
     165/**
     166  Start this driver on ControllerHandle.
     167
     168  @param[in]  This                   Protocol instance pointer.
     169  @param[in]  ControllerHandle       Handle of device to bind driver to.
     170  @param[in]  RemainingDevicePath    Optional parameter use to pick a specific child
     171                                     device to start.
     172
     173  @retval EFI_SUCCESS            The driver was added to ControllerHandle.
     174  @retval EFI_OUT_OF_RESOURCES   There are not enough resources to start the
     175                                 driver.
     176  @retval other                  The driver cannot be added to ControllerHandle.
     177
     178**/
     179EFI_STATUS
     180EFIAPI
     181Tcp6DriverBindingStart (
     182  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     183  IN EFI_HANDLE                   ControllerHandle,
     184  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
     185  );
     186
     187/**
     188  Stop this driver on ControllerHandle.
     189
     190  @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
     191  @param[in]  ControllerHandle  A handle to the device being stopped. The handle must
     192                                support a bus specific I/O protocol for the driver
     193                                to use to stop the device.
     194  @param[in]  NumberOfChildren  The number of child device handles in ChildHandleBuffer.
     195  @param[in]  ChildHandleBuffer An array of child handles to be freed. May be NULL
     196                                if NumberOfChildren is 0.
     197
     198  @retval EFI_SUCCESS           The device was stopped.
     199  @retval EFI_DEVICE_ERROR      The device could not be stopped due to a device error.
     200
     201**/
     202EFI_STATUS
     203EFIAPI
     204Tcp6DriverBindingStop (
    139205  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,
    140206  IN  EFI_HANDLE                   ControllerHandle,
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/TcpDxe/TcpDxe.inf

    r48674 r58459  
    1 ## @file TcpDxe.inf
    2 Component description file for Tcp module.
     1## @file
     2TCPv4 I/O and TCPv6 I/O services.
    33#
    4 #  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4#  This module provides EFI TCPv4 Protocol and EFI TCPv6 Protocol to send and receive data stream.
     5#  It might provide TCPv4 Protocol or TCPv6 Protocol or both of them that depends on
     6#  which network stack has been loaded in system.
     7#
     8#
     9#  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    510#
    611#  This program and the accompanying materials
     
    2227  ENTRY_POINT                    = TcpDriverEntryPoint
    2328  UNLOAD_IMAGE                   = NetLibDefaultUnload
     29  MODULE_UNI_FILE                = TcpDxe.uni
    2430
    2531#
     
    7278
    7379[Protocols]
    74   gEfiDevicePathProtocolGuid                    # PROTOCOL ALWAYS_CONSUMED
    75   gEfiIp4ProtocolGuid                           # PROTOCOL ALWAYS_CONSUMED
    76   gEfiIp4ServiceBindingProtocolGuid             # PROTOCOL ALWAYS_CONSUMED
    77   gEfiTcp4ProtocolGuid                          # PROTOCOL SOMETIMES_PRODUCED
    78   gEfiTcp4ServiceBindingProtocolGuid            # PROTOCOL ALWAYS_PRODUCED
    79   gEfiIp6ProtocolGuid                           # PROTOCOL ALWAYS_CONSUMED
    80   gEfiIp6ServiceBindingProtocolGuid             # PROTOCOL ALWAYS_CONSUMED
    81   gEfiTcp6ProtocolGuid                          # PROTOCOL SOMETIMES_PRODUCED
    82   gEfiTcp6ServiceBindingProtocolGuid            # PROTOCOL ALWAYS_PRODUCED
     80  ## SOMETIMES_CONSUMES
     81  ## SOMETIMES_PRODUCES
     82  gEfiDevicePathProtocolGuid
     83  gEfiIp4ProtocolGuid                           ## TO_START
     84  gEfiIp4ServiceBindingProtocolGuid             ## TO_START
     85  gEfiTcp4ProtocolGuid                          ## BY_START
     86  gEfiTcp4ServiceBindingProtocolGuid            ## BY_START
     87  gEfiIp6ProtocolGuid                           ## TO_START
     88  gEfiIp6ServiceBindingProtocolGuid             ## TO_START
     89  gEfiTcp6ProtocolGuid                          ## BY_START
     90  gEfiTcp6ServiceBindingProtocolGuid            ## BY_START
    8391
     92[UserExtensions.TianoCore."ExtraFiles"]
     93  TcpDxeExtra.uni
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/TcpDxe/TcpFunc.h

    r48674 r58459  
    22  Declaration of external functions shared in TCP driver.
    33
    4   Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    278278
    279279/**
    280   Set the Tcp variable data.
    281 
    282   @param[in]  TcpService        Tcp service data.
    283 
    284   @retval EFI_OUT_OF_RESOURCES  There are not enough resources to set the variable.
    285   @retval other                 Set variable failed.
    286 
    287 **/
    288 EFI_STATUS
    289 TcpSetVariableData (
    290   IN TCP_SERVICE_DATA  *TcpService
    291   );
    292 
    293 /**
    294   Clear the variable and free the resource.
    295 
    296   @param[in]  TcpService            Tcp service data.
    297 
    298 **/
    299 VOID
    300 TcpClearVariableData (
    301   IN TCP_SERVICE_DATA  *TcpService
    302   );
    303 
    304 /**
    305280  Install the device path protocol on the TCP instance.
    306281
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/TcpDxe/TcpIo.c

    r48674 r58459  
    22  Implementation of I/O interfaces between TCP and IpIoLib.
    33
    4   Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    113113      // the destination address can't be overridden, so reset the Dest to NULL.
    114114      //
    115       Dest = NULL;
     115      if (!Tcb->RemoteIpZero) {
     116        Dest = NULL;
     117      }
    116118    }
    117119  }
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/TcpDxe/TcpMain.h

    r48674 r58459  
    33  It is the common head file for all Tcp*.c in TCP driver.
    44
    5   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     5  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    66
    77  This program and the accompanying materials
     
    2222#include <Library/IpIoLib.h>
    2323#include <Library/DevicePathLib.h>
     24#include <Library/PrintLib.h>
    2425
    2526#include "Socket.h"
     
    3334extern EFI_COMPONENT_NAME_PROTOCOL   gTcpComponentName;
    3435extern EFI_COMPONENT_NAME2_PROTOCOL  gTcpComponentName2;
     36extern EFI_UNICODE_STRING_TABLE      *gTcpControllerNameTable;
    3537
    3638extern LIST_ENTRY                    mTcpRunQue;
     
    9092  EFI_IPv4_ADDRESS  *GatewayAddress;
    9193} TCP4_ROUTE_INFO;
     94
     95typedef struct {
     96  EFI_SERVICE_BINDING_PROTOCOL  *ServiceBinding;
     97  UINTN                         NumberOfChildren;
     98  EFI_HANDLE                    *ChildHandleBuffer;
     99} TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT;
    92100
    93101//
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/TcpDxe/TcpMisc.c

    r48674 r58459  
    22  Misc support routines for TCP driver.
    33
    4   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    468468
    469469  TcpProto = (TCP_PROTO_DATA *) Tcb->Sk->ProtoReserved;
    470   TcpSetVariableData (TcpProto->TcpService);
    471470
    472471  return 0;
     
    942941
    943942  NetbufFree (Nbuf);
    944 }
    945 
    946 /**
    947   Set the Tcp variable data.
    948 
    949   @param[in]  TcpService        Tcp service data.
    950 
    951   @retval EFI_OUT_OF_RESOURCES  There are not enough resources to set the variable.
    952   @retval other                 Set variable failed.
    953 
    954 **/
    955 EFI_STATUS
    956 TcpSetVariableData (
    957   IN TCP_SERVICE_DATA  *TcpService
    958   )
    959 {
    960   EFI_GUID                *ServiceBindingGuid;
    961   UINT32                  NumConfiguredInstance;
    962   LIST_ENTRY              *Entry;
    963   TCP_CB                  *TcpPcb;
    964   TCP_PROTO_DATA          *TcpProto;
    965   UINTN                   VariableDataSize;
    966   EFI_TCP4_VARIABLE_DATA  *Tcp4VariableData;
    967   EFI_TCP4_SERVICE_POINT  *Tcp4ServicePoint;
    968   EFI_TCP6_VARIABLE_DATA  *Tcp6VariableData;
    969   EFI_TCP6_SERVICE_POINT  *Tcp6ServicePoint;
    970   VOID                    *VariableData;
    971   CHAR16                  *NewMacString;
    972   EFI_STATUS              Status;
    973 
    974   if (TcpService->IpVersion == IP_VERSION_4) {
    975     ServiceBindingGuid = &gEfiTcp4ServiceBindingProtocolGuid;
    976   } else {
    977     ServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid;
    978   }
    979 
    980   NumConfiguredInstance = 0;
    981   Tcp4VariableData      = NULL;
    982   Tcp6VariableData      = NULL;
    983 
    984   //
    985   // Go through the running queue to count the instances.
    986   //
    987   NET_LIST_FOR_EACH (Entry, &mTcpRunQue) {
    988     TcpPcb    = NET_LIST_USER_STRUCT (Entry, TCP_CB, List);
    989 
    990     TcpProto  = (TCP_PROTO_DATA *) TcpPcb->Sk->ProtoReserved;
    991 
    992     if (TcpProto->TcpService == TcpService) {
    993       //
    994       // This tcp instance belongs to the TcpService.
    995       //
    996       NumConfiguredInstance++;
    997     }
    998   }
    999 
    1000   //
    1001   // Go through the listening queue to count the instances.
    1002   //
    1003   NET_LIST_FOR_EACH (Entry, &mTcpListenQue) {
    1004     TcpPcb    = NET_LIST_USER_STRUCT (Entry, TCP_CB, List);
    1005 
    1006     TcpProto  = (TCP_PROTO_DATA *) TcpPcb->Sk->ProtoReserved;
    1007 
    1008     if (TcpProto->TcpService == TcpService) {
    1009       //
    1010       // This tcp instance belongs to the TcpService.
    1011       //
    1012       NumConfiguredInstance++;
    1013     }
    1014   }
    1015 
    1016   Tcp4ServicePoint = NULL;
    1017   Tcp6ServicePoint = NULL;
    1018 
    1019   //
    1020   // Calculate the size of the Tcp4VariableData. As there may be no Tcp4 child,
    1021   // we should add extra buffers for the service points only if the number of configured
    1022   // children is more than one.
    1023   //
    1024   if (TcpService->IpVersion == IP_VERSION_4) {
    1025     VariableDataSize = sizeof (EFI_TCP4_VARIABLE_DATA);
    1026 
    1027     if (NumConfiguredInstance > 1) {
    1028       VariableDataSize += sizeof (EFI_TCP4_SERVICE_POINT) * (NumConfiguredInstance - 1);
    1029     }
    1030 
    1031     Tcp4VariableData = AllocateZeroPool (VariableDataSize);
    1032     if (Tcp4VariableData == NULL) {
    1033       return EFI_OUT_OF_RESOURCES;
    1034     }
    1035 
    1036     Tcp4VariableData->DriverHandle  = TcpService->DriverBindingHandle;
    1037     Tcp4VariableData->ServiceCount  = NumConfiguredInstance;
    1038 
    1039     Tcp4ServicePoint                = &Tcp4VariableData->Services[0];
    1040     VariableData                    = Tcp4VariableData;
    1041   } else {
    1042     VariableDataSize = sizeof (EFI_TCP6_VARIABLE_DATA);
    1043 
    1044     if (NumConfiguredInstance > 1) {
    1045       VariableDataSize += sizeof (EFI_TCP6_SERVICE_POINT) * (NumConfiguredInstance - 1);
    1046     }
    1047 
    1048     Tcp6VariableData = AllocateZeroPool (VariableDataSize);
    1049     if (Tcp6VariableData == NULL) {
    1050       return EFI_OUT_OF_RESOURCES;
    1051     }
    1052 
    1053     Tcp6VariableData->DriverHandle  = TcpService->DriverBindingHandle;
    1054     Tcp6VariableData->ServiceCount  = NumConfiguredInstance;
    1055 
    1056     Tcp6ServicePoint                = &Tcp6VariableData->Services[0];
    1057     VariableData                    = Tcp6VariableData;
    1058   }
    1059 
    1060   //
    1061   // Go through the running queue to fill the service points.
    1062   //
    1063   NET_LIST_FOR_EACH (Entry, &mTcpRunQue) {
    1064     TcpPcb    = NET_LIST_USER_STRUCT (Entry, TCP_CB, List);
    1065 
    1066     TcpProto  = (TCP_PROTO_DATA *) TcpPcb->Sk->ProtoReserved;
    1067 
    1068     if (TcpProto->TcpService == TcpService) {
    1069       //
    1070       // This tcp instance belongs to the TcpService.
    1071       //
    1072       if (TcpService->IpVersion == IP_VERSION_4) {
    1073         Tcp4ServicePoint->InstanceHandle          = TcpPcb->Sk->SockHandle;
    1074         CopyMem (&Tcp4ServicePoint->LocalAddress, &TcpPcb->LocalEnd.Ip, sizeof (EFI_IPv4_ADDRESS));
    1075         Tcp4ServicePoint->LocalPort               = NTOHS (TcpPcb->LocalEnd.Port);
    1076         CopyMem (&Tcp4ServicePoint->RemoteAddress, &TcpPcb->RemoteEnd.Ip, sizeof (EFI_IPv4_ADDRESS));
    1077         Tcp4ServicePoint->RemotePort              = NTOHS (TcpPcb->RemoteEnd.Port);
    1078 
    1079         Tcp4ServicePoint++;
    1080       } else {
    1081         Tcp6ServicePoint->InstanceHandle          = TcpPcb->Sk->SockHandle;
    1082         IP6_COPY_ADDRESS (&Tcp6ServicePoint->LocalAddress, &TcpPcb->LocalEnd.Ip);
    1083         Tcp6ServicePoint->LocalPort               = NTOHS (TcpPcb->LocalEnd.Port);
    1084         IP6_COPY_ADDRESS (&Tcp6ServicePoint->RemoteAddress, &TcpPcb->RemoteEnd.Ip);
    1085         Tcp6ServicePoint->RemotePort              = NTOHS (TcpPcb->RemoteEnd.Port);
    1086 
    1087         Tcp6ServicePoint++;
    1088       }
    1089     }
    1090   }
    1091 
    1092   //
    1093   // Go through the listening queue to fill the service points.
    1094   //
    1095   NET_LIST_FOR_EACH (Entry, &mTcpListenQue) {
    1096     TcpPcb    = NET_LIST_USER_STRUCT (Entry, TCP_CB, List);
    1097 
    1098     TcpProto  = (TCP_PROTO_DATA *) TcpPcb->Sk->ProtoReserved;
    1099 
    1100     if (TcpProto->TcpService == TcpService) {
    1101       //
    1102       // This tcp instance belongs to the TcpService.
    1103       //
    1104       if (TcpService->IpVersion == IP_VERSION_4) {
    1105         Tcp4ServicePoint->InstanceHandle          = TcpPcb->Sk->SockHandle;
    1106         CopyMem (&Tcp4ServicePoint->LocalAddress, &TcpPcb->LocalEnd.Ip, sizeof (EFI_IPv4_ADDRESS));
    1107         Tcp4ServicePoint->LocalPort               = NTOHS (TcpPcb->LocalEnd.Port);
    1108         CopyMem (&Tcp4ServicePoint->RemoteAddress, &TcpPcb->RemoteEnd.Ip, sizeof (EFI_IPv4_ADDRESS));
    1109         Tcp4ServicePoint->RemotePort              = NTOHS (TcpPcb->RemoteEnd.Port);
    1110 
    1111         Tcp4ServicePoint++;
    1112       } else {
    1113         Tcp6ServicePoint->InstanceHandle          = TcpPcb->Sk->SockHandle;
    1114         IP6_COPY_ADDRESS (&Tcp6ServicePoint->LocalAddress, &TcpPcb->LocalEnd.Ip);
    1115         Tcp6ServicePoint->LocalPort               = NTOHS (TcpPcb->LocalEnd.Port);
    1116         IP6_COPY_ADDRESS (&Tcp6ServicePoint->RemoteAddress, &TcpPcb->RemoteEnd.Ip);
    1117         Tcp6ServicePoint->RemotePort              = NTOHS (TcpPcb->RemoteEnd.Port);
    1118 
    1119         Tcp6ServicePoint++;
    1120       }
    1121     }
    1122   }
    1123 
    1124   //
    1125   // Get the mac string.
    1126   //
    1127   Status = NetLibGetMacString (
    1128              TcpService->ControllerHandle,
    1129              TcpService->DriverBindingHandle,
    1130              &NewMacString
    1131              );
    1132   if (EFI_ERROR (Status)) {
    1133     goto ON_ERROR;
    1134   }
    1135 
    1136   if (TcpService->MacString != NULL) {
    1137     //
    1138     // The variable is set already. We're going to update it.
    1139     //
    1140     if (StrCmp (TcpService->MacString, NewMacString) != 0) {
    1141       //
    1142       // The mac address is changed. Delete the previous variable first.
    1143       //
    1144       gRT->SetVariable (
    1145              TcpService->MacString,
    1146              ServiceBindingGuid,
    1147              EFI_VARIABLE_BOOTSERVICE_ACCESS,
    1148              0,
    1149              NULL
    1150              );
    1151     }
    1152 
    1153     FreePool (TcpService->MacString);
    1154   }
    1155 
    1156   TcpService->MacString = NewMacString;
    1157 
    1158   Status = gRT->SetVariable (
    1159                   TcpService->MacString,
    1160                   ServiceBindingGuid,
    1161                   EFI_VARIABLE_BOOTSERVICE_ACCESS,
    1162                   VariableDataSize,
    1163                   VariableData
    1164                   );
    1165 
    1166 ON_ERROR:
    1167 
    1168   FreePool (VariableData);
    1169 
    1170   return Status;
    1171 }
    1172 
    1173 /**
    1174   Clear the variable and free the resource.
    1175 
    1176   @param[in]  TcpService            Tcp service data.
    1177 
    1178 **/
    1179 VOID
    1180 TcpClearVariableData (
    1181   IN TCP_SERVICE_DATA  *TcpService
    1182   )
    1183 {
    1184   EFI_GUID  *ServiceBindingGuid;
    1185 
    1186   ASSERT (TcpService->MacString != NULL);
    1187 
    1188   if (TcpService->IpVersion == IP_VERSION_4) {
    1189     ServiceBindingGuid = &gEfiTcp4ServiceBindingProtocolGuid;
    1190   } else {
    1191     ServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid;
    1192   }
    1193 
    1194   gRT->SetVariable (
    1195          TcpService->MacString,
    1196          ServiceBindingGuid,
    1197          EFI_VARIABLE_BOOTSERVICE_ACCESS,
    1198          0,
    1199          NULL
    1200          );
    1201 
    1202   FreePool (TcpService->MacString);
    1203   TcpService->MacString = NULL;
    1204943}
    1205944
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/TcpDxe/TcpProto.h

    r48674 r58459  
    22  TCP protocol header file.
    33
    4   Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    336336  EFI_IPv4_ADDRESS  SubnetMask;
    337337
     338
     339  BOOLEAN           RemoteIpZero;   ///< RemoteEnd.Ip is ZERO when configured.
    338340  IP_IO_IP_INFO     *IpInfo;        ///< Pointer reference to Ip used to send pkt
    339341  UINT32            Tick;           ///< 1 tick = 200ms
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Udp6Dxe/ComponentName.c

    r48674 r58459  
    22  UEFI Component Name(2) protocol implementation for UDP6 driver.
    33
    4   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    174174  }
    175175};
     176
     177GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE  *gUdp6ControllerNameTable = NULL;
    176178
    177179/**
     
    232234
    233235/**
     236  Update the component name for the Udp6 child handle.
     237
     238  @param  Udp6[in]                  A pointer to the EFI_UDP6_PROTOCOL.
     239
     240 
     241  @retval EFI_SUCCESS               Update the ControllerNameTable of this instance successfully.
     242  @retval EFI_INVALID_PARAMETER     The input parameter is invalid.
     243 
     244**/
     245EFI_STATUS
     246UpdateName (
     247  IN    EFI_UDP6_PROTOCOL             *Udp6
     248  )
     249{
     250  EFI_STATUS                       Status;
     251  CHAR16                           HandleName[64];
     252  EFI_UDP6_CONFIG_DATA             Udp6ConfigData;
     253
     254  if (Udp6 == NULL) {
     255    return EFI_INVALID_PARAMETER;
     256  }
     257
     258  //
     259  // Format the child name into the string buffer.
     260  //
     261  Status = Udp6->GetModeData (Udp6, &Udp6ConfigData, NULL, NULL, NULL);
     262  if (!EFI_ERROR (Status)) {
     263    UnicodeSPrint (HandleName, sizeof (HandleName),
     264      L"UDPv6 (SrcPort=%d, DestPort=%d)",
     265      Udp6ConfigData.StationPort,
     266      Udp6ConfigData.RemotePort
     267      );
     268  } else if (Status == EFI_NOT_STARTED) {
     269    UnicodeSPrint (HandleName, sizeof (HandleName), L"UDPv6 (Not started)");
     270  } else {
     271    UnicodeSPrint (HandleName, sizeof (HandleName), L"UDPv6 (%r)", Status);
     272  }
     273
     274  if (gUdp6ControllerNameTable != NULL) {
     275    FreeUnicodeStringTable (gUdp6ControllerNameTable);
     276    gUdp6ControllerNameTable = NULL;
     277  }
     278
     279  Status = AddUnicodeString2 (
     280             "eng",
     281             gUdp6ComponentName.SupportedLanguages,
     282             &gUdp6ControllerNameTable,
     283             HandleName,
     284             TRUE
     285             );
     286  if (EFI_ERROR (Status)) {
     287    return Status;
     288  }
     289
     290  return AddUnicodeString2 (
     291           "en",
     292           gUdp6ComponentName2.SupportedLanguages,
     293           &gUdp6ControllerNameTable,
     294           HandleName,
     295           FALSE
     296           );
     297}
     298
     299/**
    234300  Retrieves a Unicode string that is the user-readable name of the controller
    235301  that is being managed by a driver.
     
    309375  )
    310376{
    311   return EFI_UNSUPPORTED;
     377  EFI_STATUS                    Status;
     378  EFI_UDP6_PROTOCOL             *Udp6;
     379
     380  //
     381  // Only provide names for child handles.
     382  //
     383  if (ChildHandle == NULL) {
     384    return EFI_UNSUPPORTED;
     385  }
     386
     387  //
     388  // Make sure this driver produced ChildHandle
     389  //
     390  Status = EfiTestChildHandle (
     391             ControllerHandle,
     392             ChildHandle,
     393             &gEfiIp6ProtocolGuid
     394             );
     395  if (EFI_ERROR (Status)) {
     396    return Status;
     397  }
     398
     399  //
     400  // Retrieve an instance of a produced protocol from ChildHandle
     401  //
     402  Status = gBS->OpenProtocol (
     403                  ChildHandle,
     404                  &gEfiUdp6ProtocolGuid,
     405                  (VOID **)&Udp6,
     406                  NULL,
     407                  NULL,
     408                  EFI_OPEN_PROTOCOL_GET_PROTOCOL
     409                  );
     410  if (EFI_ERROR (Status)) {
     411    return Status;
     412  }
     413
     414  //
     415  // Update the component name for this child handle.
     416  //
     417  Status = UpdateName (Udp6);
     418  if (EFI_ERROR (Status)) {
     419    return Status;
     420  }
     421
     422  return LookupUnicodeString2 (
     423           Language,
     424           This->SupportedLanguages,
     425           gUdp6ControllerNameTable,
     426           ControllerName,
     427           (BOOLEAN)(This == &gUdp6ComponentName)
     428           );
    312429}
    313 
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Udp6Dxe/Udp6Driver.c

    r48674 r58459  
    22  Driver Binding functions and Service Binding functions for the Network driver module.
    33
    4   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    166166    Udp6CleanService (Udp6Service);
    167167    goto EXIT;
    168   } else {
    169     Status = Udp6SetVariableData (Udp6Service);
    170168  }
    171169
     
    177175  }
    178176  return Status;
     177}
     178
     179/**
     180  Callback function which provided by user to remove one node in NetDestroyLinkList process.
     181 
     182  @param[in]    Entry           The entry to be removed.
     183  @param[in]    Context         Pointer to the callback context corresponds to the Context in NetDestroyLinkList.
     184
     185  @retval EFI_SUCCESS           The entry has been removed successfully.
     186  @retval Others                Fail to remove the entry.
     187
     188**/
     189EFI_STATUS
     190EFIAPI
     191Udp6DestroyChildEntryInHandleBuffer (
     192  IN LIST_ENTRY         *Entry,
     193  IN VOID               *Context
     194  )
     195{
     196  UDP6_INSTANCE_DATA            *Instance;
     197  EFI_SERVICE_BINDING_PROTOCOL  *ServiceBinding;
     198  UINTN                         NumberOfChildren;
     199  EFI_HANDLE                    *ChildHandleBuffer;
     200
     201  if (Entry == NULL || Context == NULL) {
     202    return EFI_INVALID_PARAMETER;
     203  }
     204
     205  Instance = NET_LIST_USER_STRUCT_S (Entry, UDP6_INSTANCE_DATA, Link, UDP6_INSTANCE_DATA_SIGNATURE);
     206  ServiceBinding    = ((UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding;
     207  NumberOfChildren  = ((UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren;
     208  ChildHandleBuffer = ((UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer;
     209
     210  if (!NetIsInHandleBuffer (Instance->ChildHandle, NumberOfChildren, ChildHandleBuffer)) {
     211    return EFI_SUCCESS;
     212  }
     213
     214  return ServiceBinding->DestroyChild (ServiceBinding, Instance->ChildHandle);
    179215}
    180216
     
    212248  EFI_SERVICE_BINDING_PROTOCOL  *ServiceBinding;
    213249  UDP6_SERVICE_DATA             *Udp6Service;
    214   UDP6_INSTANCE_DATA            *Instance;
     250  LIST_ENTRY                    *List;
     251  UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context;
    215252
    216253  //
     
    219256  NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiIp6ProtocolGuid);
    220257  if (NicHandle == NULL) {
    221     return EFI_DEVICE_ERROR;
     258    return EFI_SUCCESS;
    222259  }
    223260
     
    239276  Udp6Service = UDP6_SERVICE_DATA_FROM_THIS (ServiceBinding);
    240277
    241   if (NumberOfChildren == 0) {
    242 
     278  if (NumberOfChildren != 0) {
     279    //
     280    // NumberOfChildren is not zero, destroy the children instances in ChildHandleBuffer.
     281    //
     282    List = &Udp6Service->ChildrenList;
     283    Context.ServiceBinding    = ServiceBinding;
     284    Context.NumberOfChildren  = NumberOfChildren;
     285    Context.ChildHandleBuffer = ChildHandleBuffer;
     286    Status = NetDestroyLinkList (
     287               List,
     288               Udp6DestroyChildEntryInHandleBuffer,
     289               &Context,
     290               NULL
     291               );
     292  } else if (IsListEmpty (&Udp6Service->ChildrenList)) {
    243293    gBS->UninstallMultipleProtocolInterfaces (
    244294           NicHandle,
     
    247297           NULL
    248298           );
    249 
    250     Udp6ClearVariableData (Udp6Service);
    251 
     299 
    252300    Udp6CleanService (Udp6Service);
    253301
    254302    FreePool (Udp6Service);
    255   } else {
    256 
    257     while (!IsListEmpty (&Udp6Service->ChildrenList)) {
    258       Instance = NET_LIST_HEAD (&Udp6Service->ChildrenList, UDP6_INSTANCE_DATA, Link);
    259 
    260       Status = ServiceBinding->DestroyChild (ServiceBinding, Instance->ChildHandle);
    261     }
     303
     304    Status = EFI_SUCCESS;
    262305  }
    263306
     
    352395  }
    353396
     397  //
     398  // Open this instance's Ip6 protocol in the IpInfo BY_CHILD.
     399  //
     400  Status = gBS->OpenProtocol (
     401                  Instance->IpInfo->ChildHandle,
     402                  &gEfiIp6ProtocolGuid,
     403                  (VOID **) &Ip6,
     404                  gUdp6DriverBinding.DriverBindingHandle,
     405                  Instance->ChildHandle,
     406                  EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
     407                  );
     408  if (EFI_ERROR (Status)) {
     409    goto ON_ERROR;
     410  }
     411 
    354412  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
    355413
     
    441499  Instance = UDP6_INSTANCE_DATA_FROM_THIS (Udp6Proto);
    442500
    443   if (Instance->Destroyed) {
     501  if (Instance->InDestroy) {
    444502    return EFI_SUCCESS;
    445503  }
     
    448506  // Use the Destroyed flag to avoid the re-entering of the following code.
    449507  //
    450   Instance->Destroyed = TRUE;
    451 
    452   //
    453   // Close the Ip6 protocol.
     508  Instance->InDestroy = TRUE;
     509
     510  //
     511  // Close the Ip6 protocol on the default IpIo.
    454512  //
    455513  gBS->CloseProtocol (
     
    459517         Instance->ChildHandle
    460518         );
     519  //
     520  // Close the Ip6 protocol on this instance's IpInfo.
     521  //
     522  gBS->CloseProtocol (
     523         Instance->IpInfo->ChildHandle,
     524         &gEfiIp6ProtocolGuid,
     525         gUdp6DriverBinding.DriverBindingHandle,
     526         Instance->ChildHandle
     527         );
    461528
    462529  //
     
    470537                  );
    471538  if (EFI_ERROR (Status)) {
    472     Instance->Destroyed = FALSE;
     539    Instance->InDestroy = FALSE;
    473540    return Status;
    474541  }
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Udp6Dxe/Udp6Dxe.inf

    r48674 r58459  
    11## @file Udp6Dxe.inf
    2 #  Component description file for Udp6 module.
    3 #
    4 #  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     2#  UDP packet service based on IPv6 stack.
     3
     4#  This module produces EFI UDPv6 Protocol which provides simple packet-oriented
     5#  services to transmit and receive UDP packets.
     6#                                                                               
     7#  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    58#
    69#  This program and the accompanying materials
     
    2326  ENTRY_POINT                    = Udp6DriverEntryPoint
    2427  UNLOAD_IMAGE                   = NetLibDefaultUnload
     28  MODULE_UNI_FILE                = Udp6Dxe.uni
    2529
    2630#
     
    5761
    5862[Protocols]
    59   gEfiIp6ProtocolGuid                           # PROTOCOL ALWAYS_CONSUMED
    60   gEfiIp6ServiceBindingProtocolGuid             # PROTOCOL ALWAYS_CONSUMED
    61   gEfiUdp6ServiceBindingProtocolGuid            # PROTOCOL ALWAYS_CONSUMED
    62   gEfiUdp6ProtocolGuid                          # PROTOCOL ALWAYS_CONSUMED
     63  gEfiIp6ProtocolGuid                           ## TO_START
     64  gEfiIp6ServiceBindingProtocolGuid             ## TO_START
     65  gEfiUdp6ServiceBindingProtocolGuid            ## BY_START
     66  gEfiUdp6ProtocolGuid                          ## BY_START
    6367
     68[UserExtensions.TianoCore."ExtraFiles"]
     69  Udp6DxeExtra.uni
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Udp6Dxe/Udp6Impl.c

    r48674 r58459  
    22  Udp6 driver's whole implementation.
    33
    4   Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    364364
    365365  IpIoDestroy (Udp6Service->IpIo);
    366 
     366  Udp6Service->IpIo = NULL;
     367 
    367368  return Status;
    368369}
     
    389390  //
    390391  IpIoDestroy (Udp6Service->IpIo);
     392  Udp6Service->IpIo = NULL;
     393 
     394  ZeroMem (Udp6Service, sizeof (UDP6_SERVICE_DATA));
    391395}
    392396
     
    492496  Instance->Configured  = FALSE;
    493497  Instance->IsNoMapping = FALSE;
    494   Instance->Destroyed   = FALSE;
     498  Instance->InDestroy   = FALSE;
    495499}
    496500
     
    16201624  }
    16211625
    1622   gRT->GetTime (&RxData.TimeStamp, NULL);
    1623 
    16241626  Udp6Session                  = &RxData.UdpSession;
    16251627  Udp6Session->SourcePort      = NTOHS (Udp6Header->SrcPort);
     
    19301932  )
    19311933{
    1932 }
    1933 
    1934 
    1935 /**
    1936   Set the Udp6 variable data.
    1937 
    1938   @param[in]  Udp6Service            Udp6 service data.
    1939 
    1940   @retval     EFI_OUT_OF_RESOURCES   There are not enough resources to set the
    1941                                      variable.
    1942   @retval     other                  Set variable failed.
    1943 
    1944 **/
    1945 EFI_STATUS
    1946 Udp6SetVariableData (
    1947   IN UDP6_SERVICE_DATA  *Udp6Service
    1948   )
    1949 {
    1950   UINT32                  NumConfiguredInstance;
    1951   LIST_ENTRY              *Entry;
    1952   UINTN                   VariableDataSize;
    1953   EFI_UDP6_VARIABLE_DATA  *Udp6VariableData;
    1954   EFI_UDP6_SERVICE_POINT  *Udp6ServicePoint;
    1955   UDP6_INSTANCE_DATA      *Udp6Instance;
    1956   CHAR16                  *NewMacString;
    1957   EFI_STATUS              Status;
    1958 
    1959   NumConfiguredInstance = 0;
    1960 
    1961   //
    1962   // Go through the children list to count the configured children.
    1963   //
    1964   NET_LIST_FOR_EACH (Entry, &Udp6Service->ChildrenList) {
    1965     Udp6Instance = NET_LIST_USER_STRUCT_S (
    1966                      Entry,
    1967                      UDP6_INSTANCE_DATA,
    1968                      Link,
    1969                      UDP6_INSTANCE_DATA_SIGNATURE
    1970                      );
    1971 
    1972     if (Udp6Instance->Configured) {
    1973       NumConfiguredInstance++;
    1974     }
    1975   }
    1976 
    1977   //
    1978   // Calculate the size of the Udp6VariableData. As there may be no Udp6 child,
    1979   // we should add extra buffer for the service points only if the number of configured
    1980   // children is more than 1.
    1981   //
    1982   VariableDataSize = sizeof (EFI_UDP6_VARIABLE_DATA);
    1983 
    1984   if (NumConfiguredInstance > 1) {
    1985     VariableDataSize += sizeof (EFI_UDP6_SERVICE_POINT) * (NumConfiguredInstance - 1);
    1986   }
    1987 
    1988   Udp6VariableData = AllocateZeroPool (VariableDataSize);
    1989   if (Udp6VariableData == NULL) {
    1990     return EFI_OUT_OF_RESOURCES;
    1991   }
    1992 
    1993   Udp6VariableData->DriverHandle = Udp6Service->ImageHandle;
    1994   Udp6VariableData->ServiceCount = NumConfiguredInstance;
    1995 
    1996   Udp6ServicePoint = &Udp6VariableData->Services[0];
    1997 
    1998   //
    1999   // Go through the children list to fill the configured children's address pairs.
    2000   //
    2001   NET_LIST_FOR_EACH (Entry, &Udp6Service->ChildrenList) {
    2002     Udp6Instance = NET_LIST_USER_STRUCT_S (
    2003                      Entry,
    2004                      UDP6_INSTANCE_DATA,
    2005                      Link,
    2006                      UDP6_INSTANCE_DATA_SIGNATURE
    2007                      );
    2008 
    2009     if (Udp6Instance->Configured) {
    2010       Udp6ServicePoint->InstanceHandle = Udp6Instance->ChildHandle;
    2011       Udp6ServicePoint->LocalPort      = Udp6Instance->ConfigData.StationPort;
    2012       Udp6ServicePoint->RemotePort     = Udp6Instance->ConfigData.RemotePort;
    2013 
    2014       IP6_COPY_ADDRESS (
    2015         &Udp6ServicePoint->LocalAddress,
    2016         &Udp6Instance->ConfigData.StationAddress
    2017         );
    2018       IP6_COPY_ADDRESS (
    2019         &Udp6ServicePoint->RemoteAddress,
    2020         &Udp6Instance->ConfigData.RemoteAddress
    2021         );
    2022       Udp6ServicePoint++;
    2023     }
    2024   }
    2025 
    2026   //
    2027   // Get the MAC string.
    2028   //
    2029   Status = NetLibGetMacString (
    2030              Udp6Service->ControllerHandle,
    2031              Udp6Service->ImageHandle,
    2032              &NewMacString
    2033              );
    2034   if (EFI_ERROR (Status)) {
    2035     goto EXIT;
    2036   }
    2037 
    2038   if (Udp6Service->MacString != NULL) {
    2039     //
    2040     // The variable is set already, we're going to update it.
    2041     //
    2042     if (StrCmp (Udp6Service->MacString, NewMacString) != 0) {
    2043       //
    2044       // The MAC address is changed, delete the previous variable first.
    2045       //
    2046       gRT->SetVariable (
    2047              Udp6Service->MacString,
    2048              &gEfiUdp6ServiceBindingProtocolGuid,
    2049              EFI_VARIABLE_BOOTSERVICE_ACCESS,
    2050              0,
    2051              NULL
    2052              );
    2053     }
    2054 
    2055     FreePool (Udp6Service->MacString);
    2056   }
    2057 
    2058   Udp6Service->MacString = NewMacString;
    2059 
    2060   Status = gRT->SetVariable (
    2061                   Udp6Service->MacString,
    2062                   &gEfiUdp6ServiceBindingProtocolGuid,
    2063                   EFI_VARIABLE_BOOTSERVICE_ACCESS,
    2064                   VariableDataSize,
    2065                   (VOID *) Udp6VariableData
    2066                   );
    2067 
    2068 EXIT:
    2069 
    2070   FreePool (Udp6VariableData);
    2071 
    2072   return Status;
    2073 }
    2074 
    2075 
    2076 /**
    2077   Clear the variable and free the resource.
    2078 
    2079   @param[in, out]  Udp6Service            Udp6 service data.
    2080 
    2081 **/
    2082 VOID
    2083 Udp6ClearVariableData (
    2084   IN OUT UDP6_SERVICE_DATA  *Udp6Service
    2085   )
    2086 {
    2087   ASSERT (Udp6Service->MacString != NULL);
    2088 
    2089   gRT->SetVariable (
    2090          Udp6Service->MacString,
    2091          &gEfiUdp6ServiceBindingProtocolGuid,
    2092          EFI_VARIABLE_BOOTSERVICE_ACCESS,
    2093          0,
    2094          NULL
    2095          );
    2096 
    2097   FreePool (Udp6Service->MacString);
    2098   Udp6Service->MacString = NULL;
    2099 }
    2100 
     1934}
    21011935
    21021936/**
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Udp6Dxe/Udp6Impl.h

    r48674 r58459  
    22  Udp6 driver's whole implementation and internal data structures.
    33
    4   Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    3131#include <Library/MemoryAllocationLib.h>
    3232#include <Library/DpcLib.h>
     33#include <Library/PrintLib.h>
    3334
    3435#include "Udp6Driver.h"
     
    3637extern EFI_COMPONENT_NAME2_PROTOCOL   gUdp6ComponentName2;
    3738extern EFI_COMPONENT_NAME_PROTOCOL    gUdp6ComponentName;
     39extern EFI_UNICODE_STRING_TABLE       *gUdp6ControllerNameTable;
    3840extern EFI_SERVICE_BINDING_PROTOCOL   mUdp6ServiceBinding;
    3941extern EFI_UDP6_PROTOCOL              mUdp6Protocol;
     
    7880  IP_IO                         *IpIo;
    7981  EFI_EVENT                     TimeoutEvent;
    80   CHAR16                        *MacString;
    81 } UDP6_SERVICE_DATA;
     82 } UDP6_SERVICE_DATA;
    8283
    8384typedef struct _UDP6_INSTANCE_DATA {
     
    9899  EFI_STATUS            IcmpError;
    99100  IP_IO_IP_INFO         *IpInfo;
    100   BOOLEAN               Destroyed;
     101  BOOLEAN               InDestroy;
    101102} UDP6_INSTANCE_DATA;
    102103
     
    108109} UDP6_RXDATA_WRAP;
    109110
     111typedef struct {
     112  EFI_SERVICE_BINDING_PROTOCOL  *ServiceBinding;
     113  UINTN                         NumberOfChildren;
     114  EFI_HANDLE                    *ChildHandleBuffer;
     115} UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT;
     116
    110117/**
    111118  Clean the Udp service context data.
     
    138145  IN EFI_HANDLE         ControllerHandle
    139146  );
    140 
    141 /**
    142   Set the Udp6 variable data.
    143 
    144   @param[in]  Udp6Service            Udp6 service data.
    145 
    146   @retval     EFI_OUT_OF_RESOURCES   There are not enough resources to set the
    147                                      variable.
    148   @retval     other                  Set variable failed.
    149 
    150 **/
    151 EFI_STATUS
    152 Udp6SetVariableData (
    153   IN UDP6_SERVICE_DATA  *Udp6Service
    154   );
    155 
     147 
    156148/**
    157149  This function cleans the udp instance.
     
    164156  IN OUT UDP6_INSTANCE_DATA  *Instance
    165157  );
    166 
    167 /**
    168   Clear the variable and free the resource.
    169 
    170   @param[in, out]  Udp6Service            Udp6 service data.
    171 
    172 **/
    173 VOID
    174 Udp6ClearVariableData (
    175   IN OUT UDP6_SERVICE_DATA  *Udp6Service
    176   );
    177 
     158 
    178159/**
    179160  This function intializes the new created udp instance.
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Udp6Dxe/Udp6Main.c

    r48674 r58459  
    22  Contains all EFI_UDP6_PROTOCOL interfaces.
    33
    4   Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    276276    // Cancel all the user tokens.
    277277    //
    278     Status = Instance->Udp6Proto.Cancel (&Instance->Udp6Proto, NULL);
     278    Instance->Udp6Proto.Cancel (&Instance->Udp6Proto, NULL);
    279279
    280280    //
     
    285285    ASSERT (IsListEmpty (&Instance->DeliveredDgramQue));
    286286  }
    287 
    288   Status = Udp6SetVariableData (Instance->Udp6Service);
    289 
     287 
    290288ON_EXIT:
    291289
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/UefiPxeBcDxe/ComponentName.c

    r48674 r58459  
    22  UEFI Component Name(2) protocol implementation for UefiPxeBc driver.
    33
    4   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    172172};
    173173
     174GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE       mPxeBcControllerNameTable[] = {
     175  {
     176    "eng;en",
     177    L"PXE Controller"
     178  },
     179  {
     180    NULL,
     181    NULL
     182  }
     183};
    174184
    175185/**
     
    308318  )
    309319{
    310   return EFI_UNSUPPORTED;
     320  EFI_STATUS                      Status;
     321  EFI_HANDLE                      NicHandle;
     322  PXEBC_PRIVATE_PROTOCOL          *Id;
     323
     324  if (ControllerHandle == NULL || ChildHandle != NULL) {
     325    return EFI_UNSUPPORTED;
     326  }
     327 
     328  NicHandle = PxeBcGetNicByIp4Children (ControllerHandle);
     329  if (NicHandle == NULL) {
     330    NicHandle = PxeBcGetNicByIp6Children (ControllerHandle);
     331    if (NicHandle == NULL) {
     332      return EFI_UNSUPPORTED;
     333    }
     334  }
     335
     336  //
     337  // Try to retrieve the private data by PxeBcPrivate protocol.
     338  //
     339  Status = gBS->OpenProtocol (
     340                  NicHandle,
     341                  &gEfiCallerIdGuid,
     342                  (VOID **) &Id,
     343                  NULL,
     344                  NULL,
     345                  EFI_OPEN_PROTOCOL_GET_PROTOCOL
     346                  );
     347  if (EFI_ERROR (Status)) {
     348    return Status;
     349  }
     350
     351  return LookupUnicodeString2 (
     352           Language,
     353           This->SupportedLanguages,
     354           mPxeBcControllerNameTable,
     355           ControllerName,
     356           (BOOLEAN)(This == &gPxeBcComponentName)
     357           );
    311358}
    312 
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/UefiPxeBcDxe/PxeBcBoot.c

    r48674 r58459  
    22  Boot functions implementation for UefiPxeBc Driver.
    33
    4   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    8787
    8888  //
    89   // Only ProxyPxe10 offer needs boot prompt.
    90   //
    91   if (OfferType != PxeOfferTypeProxyPxe10) {
     89  // Only DhcpPxe10 and ProxyPxe10 offer needs boot prompt.
     90  //
     91  if (OfferType != PxeOfferTypeProxyPxe10 && OfferType != PxeOfferTypeDhcpPxe10) {
    9292    return EFI_NOT_FOUND;
    9393  }
     
    9999
    100100  VendorOpt = &Cache->Dhcp4.VendorOpt;
     101  //
     102  // According to the PXE specification 2.1, Table 2-1 PXE DHCP Options,
     103  // we must not consider a boot prompt or boot menu if all of the following hold:
     104  //   - the PXE_DISCOVERY_CONTROL tag(6) is present inside the Vendor Options(43), and has bit 3 set 
     105  //   - a boot file name has been presented in the initial DHCP or ProxyDHCP offer packet.
     106  //
     107  if (IS_DISABLE_PROMPT_MENU (VendorOpt->DiscoverCtrl) &&
     108      Cache->Dhcp4.OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] != NULL) {
     109    return EFI_ABORTED;
     110  }
     111 
    101112  if (!IS_VALID_BOOT_PROMPT (VendorOpt->BitMap)) {
    102     return EFI_SUCCESS;
     113    return EFI_TIMEOUT;
    103114  }
    104115
     
    111122  //
    112123  if (Timeout == 0) {
     124    return EFI_TIMEOUT;
     125  }
     126  if (Timeout == 255) {
    113127    return EFI_SUCCESS;
    114   }
    115   if (Timeout == 255) {
    116     return EFI_TIMEOUT;
    117128  }
    118129
     
    174185  AsciiPrint ("(%d) ", Timeout--);
    175186
     187  Status = EFI_TIMEOUT;
    176188  while (EFI_ERROR (gBS->CheckEvent (TimeoutEvent))) {
    177189    if (!EFI_ERROR (gBS->CheckEvent (DescendEvent))) {
     
    185197    //
    186198    // Parse the input key by user.
     199    // If <F8> or <Ctrl> + <M> is pressed, return success to display the boot menu.
    187200    //
    188201    if (InputKey.ScanCode == 0) {
     
    197210      case 'm':
    198211      case 'M':
    199         Status = EFI_TIMEOUT;
     212        Status = EFI_SUCCESS;
    200213        break;
    201214
     
    209222
    210223      case SCAN_F8:
    211         Status = EFI_TIMEOUT;
     224        Status = EFI_SUCCESS;
    212225        break;
    213226
     
    277290
    278291  Finish    = FALSE;
    279   Select    = 1;
     292  Select    = 0;
    280293  Index     = 0;
    281294  *Type     = 0;
     
    285298
    286299  //
    287   // There is no specified ProxyPxe10 for IPv6 in PXE and UEFI spec.
     300  // There is no specified DhcpPxe10/ProxyPxe10 for IPv6 in PXE and UEFI spec.
    288301  //
    289302  ASSERT (!Mode->UsingIpv6);
    290   ASSERT (OfferType == PxeOfferTypeProxyPxe10);
     303  ASSERT (OfferType == PxeOfferTypeProxyPxe10 || OfferType == PxeOfferTypeDhcpPxe10);
    291304
    292305  VendorOpt = &Cache->Dhcp4.VendorOpt;
     
    352365    }
    353366
    354     if (InputKey.ScanCode != 0) {
     367    if (InputKey.ScanCode == 0) {
    355368      switch (InputKey.UnicodeChar) {
    356369      case CTRL ('c'):
     
    456469  PXEBC_DHCP4_PACKET_CACHE    *Cache4;
    457470  UINT16                      Value;
    458 
     471  PXEBC_VENDOR_OPTION         *VendorOpt;
     472  PXEBC_BOOT_SVR_ENTRY        *Entry;
     473 
    459474  PxeBc       = &Private->PxeBc;
    460475  Mode        = PxeBc->Mode;
     
    473488  }
    474489
    475   //
    476   // Parse the boot server Ipv4 address by next server address.
    477   // If this field isn't available, use option 54 instead.
    478   //
    479   CopyMem (
    480     &Private->ServerIp,
    481     &Cache4->Packet.Offer.Dhcp4.Header.ServerAddr,
    482     sizeof (EFI_IPv4_ADDRESS)
    483     );
    484 
     490  ASSERT (Cache4->OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] != NULL);
     491
     492  //
     493  // Parse the boot server address.
     494  // If prompt/discover is disabled, get the first boot server from the boot servers list.
     495  // Otherwise, parse the boot server Ipv4 address from next server address field in DHCP header.
     496  // If all these fields are not available, use option 54 instead.
     497  //
     498  VendorOpt = &Cache4->VendorOpt;
     499  if (IS_DISABLE_PROMPT_MENU (VendorOpt->DiscoverCtrl) && IS_VALID_BOOT_SERVERS (VendorOpt->BitMap)) {
     500    Entry = VendorOpt->BootSvr;
     501    if (VendorOpt->BootSvrLen >= sizeof (PXEBC_BOOT_SVR_ENTRY) && Entry->IpCnt > 0) {
     502      CopyMem (
     503        &Private->ServerIp,
     504        &Entry->IpAddr[0],
     505        sizeof (EFI_IPv4_ADDRESS)
     506        );
     507    }
     508  }
    485509  if (Private->ServerIp.Addr[0] == 0) {
     510    //
     511    // ServerIp.Addr[0] equals zero means we failed to get IP address from boot server list.
     512    // Try to use next server address field.
     513    //
     514    CopyMem (
     515      &Private->ServerIp,
     516      &Cache4->Packet.Offer.Dhcp4.Header.ServerAddr,
     517      sizeof (EFI_IPv4_ADDRESS)
     518      );
     519  }
     520  if (Private->ServerIp.Addr[0] == 0) {
     521    //
     522    // Still failed , use the IP address from option 54.
     523    //
    486524    CopyMem (
    487525      &Private->ServerIp,
     
    494532  // Parse the boot file name by option.
    495533  //
    496   ASSERT (Cache4->OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] != NULL);
    497534  Private->BootFileName = Cache4->OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE]->Data;
    498535
     
    652689  @param[in]      Private      Pointer to PxeBc private data.
    653690  @param[in]      Type         The type of bootstrap to perform.
    654   @param[in, out] Info        Pointer to EFI_PXE_BASE_CODE_DISCOVER_INFO.
     691  @param[in, out] DiscoverInfo Pointer to EFI_PXE_BASE_CODE_DISCOVER_INFO.
    655692  @param[out]     BootEntry    Pointer to PXEBC_BOOT_SVR_ENTRY.
    656693  @param[out]     SrvList      Pointer to EFI_PXE_BASE_CODE_SRVLIST.
     
    664701  IN     PXEBC_PRIVATE_DATA               *Private,
    665702  IN     UINT16                           Type,
    666   IN OUT EFI_PXE_BASE_CODE_DISCOVER_INFO  *Info,
     703  IN OUT EFI_PXE_BASE_CODE_DISCOVER_INFO  **DiscoverInfo,
    667704     OUT PXEBC_BOOT_SVR_ENTRY             **BootEntry,
    668705     OUT EFI_PXE_BASE_CODE_SRVLIST        **SrvList
     
    674711  PXEBC_BOOT_SVR_ENTRY            *Entry;
    675712  BOOLEAN                         IsFound;
     713  EFI_PXE_BASE_CODE_DISCOVER_INFO *Info;
     714  UINT16                          Index;
    676715
    677716  Mode = Private->PxeBc.Mode;
     717  Info = *DiscoverInfo;
    678718
    679719  if (Mode->UsingIpv6) {
     
    709749    Info->UseBCast    = (BOOLEAN) !IS_DISABLE_BCAST_DISCOVER (VendorOpt->DiscoverCtrl);
    710750    Info->MustUseList = (BOOLEAN) IS_ENABLE_USE_SERVER_LIST (VendorOpt->DiscoverCtrl);
    711     Info->UseUCast    = Info->MustUseList;
     751    Info->UseUCast    = (BOOLEAN) IS_VALID_BOOT_SERVERS (VendorOpt->BitMap);
    712752
    713753    if (Info->UseMCast) {
     
    720760    Info->IpCnt = 0;
    721761
    722     if (Info->MustUseList) {
     762    if (Info->UseUCast) {
    723763      Entry = VendorOpt->BootSvr;
    724764
     
    736776
    737777      Info->IpCnt = Entry->IpCnt;
     778      if (Info->IpCnt >= 1) {
     779        *DiscoverInfo = AllocatePool (sizeof (*Info) + (Info->IpCnt - 1) * sizeof (**SrvList));
     780        if (*DiscoverInfo == NULL) {
     781          return EFI_OUT_OF_RESOURCES;       
     782        }     
     783        CopyMem (*DiscoverInfo, Info, sizeof (*Info));
     784        Info = *DiscoverInfo;
     785      }
     786
     787      for (Index = 0; Index < Info->IpCnt; Index++) {
     788        CopyMem (&Info->SrvList[Index].IpAddr, &Entry->IpAddr[Index], sizeof (EFI_IPv4_ADDRESS));
     789        Info->SrvList[Index].AcceptAnyResponse = !Info->MustUseList;
     790        Info->SrvList[Index].Type = NTOHS (Entry->Type);
     791      }
    738792    }
    739793
    740794    *BootEntry = Entry;
     795    *SrvList   = Info->SrvList;
    741796  }
    742797
     
    843898    // Choose by user's input.
    844899    //
     900    Status = PxeBcSelectBootMenu (Private, &Type, FALSE);
     901  } else if (Status == EFI_TIMEOUT) {
     902    //
     903    // Choose by default item.
     904    //
    845905    Status = PxeBcSelectBootMenu (Private, &Type, TRUE);
    846   } else if (Status == EFI_TIMEOUT) {
    847     //
    848     // Choose by default item.
    849     //
    850     Status = PxeBcSelectBootMenu (Private, &Type, FALSE);
    851906  }
    852907
     
    868923    if (EFI_ERROR (Status)) {
    869924      return Status;
     925    }
     926
     927    if (Mode->PxeReplyReceived && !Mode->ProxyOfferReceived) {
     928      //
     929      // Some network boot loader only search the packet in Mode.ProxyOffer to get its server
     930      // IP address, so we need to store a copy of Mode.PxeReply packet into Mode.ProxyOffer.
     931      //
     932      if (Mode->UsingIpv6) {
     933        CopyMem (
     934          &Mode->ProxyOffer.Dhcpv6,
     935          &Mode->PxeReply.Dhcpv6,
     936          Private->PxeReply.Dhcp6.Packet.Ack.Length
     937          );
     938      } else {
     939        CopyMem (
     940          &Mode->ProxyOffer.Dhcpv4,
     941          &Mode->PxeReply.Dhcpv4,
     942          Private->PxeReply.Dhcp4.Packet.Ack.Length
     943          );     
     944      }
     945      Mode->ProxyOfferReceived = TRUE;
    870946    }
    871947  }
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/UefiPxeBcDxe/PxeBcBoot.h

    r48674 r58459  
    22  Boot functions declaration for UefiPxeBc Driver.
    33
    4   Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    3030  @param[in]      Private      Pointer to PxeBc private data.
    3131  @param[in]      Type         The type of bootstrap to perform.
    32   @param[in, out] Info        Pointer to EFI_PXE_BASE_CODE_DISCOVER_INFO.
     32  @param[in, out] DiscoverInfo Pointer to EFI_PXE_BASE_CODE_DISCOVER_INFO.
    3333  @param[out]     BootEntry    Pointer to PXEBC_BOOT_SVR_ENTRY.
    3434  @param[out]     SrvList      Pointer to EFI_PXE_BASE_CODE_SRVLIST.
     
    4242  IN     PXEBC_PRIVATE_DATA               *Private,
    4343  IN     UINT16                           Type,
    44   IN OUT EFI_PXE_BASE_CODE_DISCOVER_INFO  *Info,
     44  IN OUT EFI_PXE_BASE_CODE_DISCOVER_INFO  **DiscoverInfo,
    4545     OUT PXEBC_BOOT_SVR_ENTRY             **BootEntry,
    4646     OUT EFI_PXE_BASE_CODE_SRVLIST        **SrvList
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c

    r48674 r58459  
    22  Functions implementation related with DHCPv4 for UefiPxeBc Driver.
    33
    4   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    473473  //
    474474  // Parse DHCPv4 options in this offer, and store the pointers.
     475  // First, try to parse DHCPv4 options from the DHCP optional parameters field.
    475476  //
    476477  for (Index = 0; Index < PXEBC_DHCP4_TAG_INDEX_MAX; Index++) {
     
    481482                       );
    482483  }
     484  //
     485  // Second, Check if bootfilename and serverhostname is overloaded to carry DHCP options refers to rfc-2132.
     486  // If yes, try to parse options from the BootFileName field, then ServerName field.
     487  //
     488  Option = Options[PXEBC_DHCP4_TAG_INDEX_OVERLOAD];
     489  if (Option != NULL) {
     490    if ((Option->Data[0] & PXEBC_DHCP4_OVERLOAD_FILE) != 0) {
     491      for (Index = 0; Index < PXEBC_DHCP4_TAG_INDEX_MAX; Index++) {
     492        if (Options[Index] == NULL) {
     493          Options[Index] = PxeBcParseDhcp4Options (
     494                             (UINT8 *) Offer->Dhcp4.Header.BootFileName,
     495                             sizeof (Offer->Dhcp4.Header.BootFileName),
     496                             mInterestedDhcp4Tags[Index]
     497                             );
     498        }
     499      }
     500    }
     501    if ((Option->Data[0] & PXEBC_DHCP4_OVERLOAD_SERVER_NAME) != 0) {
     502      for (Index = 0; Index < PXEBC_DHCP4_TAG_INDEX_MAX; Index++) {
     503        if (Options[Index] == NULL) {
     504          Options[Index] = PxeBcParseDhcp4Options (
     505                             (UINT8 *) Offer->Dhcp4.Header.ServerName,
     506                             sizeof (Offer->Dhcp4.Header.ServerName),
     507                             mInterestedDhcp4Tags[Index]
     508                             );
     509        }
     510      }
     511    }
     512  }
    483513
    484514  //
     
    507537
    508538  //
    509   // Check whether bootfilename and serverhostname overloaded, refers to rfc-2132 in details.
    510   // If overloaded, parse the buffer as nested DHCPv4 options, or else just parse as bootfilename
    511   // and serverhostname option.
    512   //
    513   Option = Options[PXEBC_DHCP4_TAG_INDEX_OVERLOAD];
    514   if (Option != NULL && (Option->Data[0] & PXEBC_DHCP4_OVERLOAD_FILE) != 0) {
    515 
    516     Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] = PxeBcParseDhcp4Options (
    517                                                 (UINT8 *) Offer->Dhcp4.Header.BootFileName,
    518                                                 sizeof (Offer->Dhcp4.Header.BootFileName),
    519                                                 PXEBC_DHCP4_TAG_BOOTFILE
    520                                                 );
     539  // Parse PXE boot file name:
     540  // According to PXE spec, boot file name should be read from DHCP option 67 (bootfile name) if present.
     541  // Otherwise, read from boot file field in DHCP header.
     542  //
     543  if (Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] != NULL) {
    521544    //
    522545    // RFC 2132, Section 9.5 does not strictly state Bootfile name (option 67) is null
    523546    // terminated string. So force to append null terminated character at the end of string.
    524547    //
    525     if (Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] != NULL) {
    526       Ptr8 =  (UINT8*)&Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE]->Data[0];
    527       Ptr8 += Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE]->Length;
    528       *Ptr8 =  '\0';
    529     }
    530 
    531   } else if ((Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] == NULL) &&
    532             (Offer->Dhcp4.Header.BootFileName[0] != 0)) {
     548    Ptr8 =  (UINT8*)&Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE]->Data[0];
     549    Ptr8 += Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE]->Length;
     550    if (*(Ptr8 - 1) != '\0') {
     551      *Ptr8 = '\0';
     552    }
     553  } else if (Offer->Dhcp4.Header.BootFileName[0] != 0) {
    533554    //
    534555    // If the bootfile is not present and bootfilename is present in DHCPv4 packet, just parse it.
    535     // Do not count dhcp option header here, or else will destory the serverhostname.
     556    // Do not count dhcp option header here, or else will destroy the serverhostname.
    536557    //
    537558    Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] = (EFI_DHCP4_PACKET_OPTION *)
     
    14441465        }
    14451466        if ((SrvList[SrvIndex].Type == Type) &&
    1446             EFI_IP4_EQUAL (&Response->Dhcp4.Header.ServerAddr, &Private->ServerIp)) {
     1467            EFI_IP4_EQUAL (&Response->Dhcp4.Header.ServerAddr, &SrvList[SrvIndex].IpAddr)) {
    14471468          break;
    14481469        }
     
    15751596  CopyMem (&PxeMode->SubnetMask, &Private->SubnetMask, sizeof (EFI_IPv4_ADDRESS));
    15761597
    1577   Status = PxeBcFlushStaionIp (Private, &Private->StationIp, &Private->SubnetMask);
     1598  Status = PxeBcFlushStationIp (Private, &Private->StationIp, &Private->SubnetMask);
    15781599  if (EFI_ERROR (Status)) {
    15791600    goto ON_EXIT;
     
    15881609
    15891610  PxeBcShowIp4Addr (&Private->StationIp.v4);
     1611  AsciiPrint ("\n");
    15901612
    15911613ON_EXIT:
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.h

    r48674 r58459  
    22  Functions declaration related with DHCPv4 for UefiPxeBc Driver.
    33
    4   Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    128128#define BIT(x)                (1 << x)
    129129#define CTRL(x)               (0x1F & (x))
    130 #define DEFAULT_CLASS_ID_DATA "PXEClient:Arch:?????:????:??????"
     130#define DEFAULT_CLASS_ID_DATA "PXEClient:Arch:xxxxx:UNDI:003000"
    131131#define DEFAULT_UNDI_TYPE     1
    132132#define DEFAULT_UNDI_MAJOR    3
     
    147147   BIT (PXEBC_VENDOR_TAG_MENU_PROMPT))
    148148
     149#define IS_VALID_BOOT_SERVERS(x) \
     150  ((((x)[0]) & BIT (PXEBC_VENDOR_TAG_BOOT_SERVERS)) \
     151   == BIT (PXEBC_VENDOR_TAG_BOOT_SERVERS)) 
     152
    149153#define IS_VALID_BOOT_PROMPT(x) \
    150154  ((((x)[0]) & BIT (PXEBC_VENDOR_TAG_MENU_PROMPT)) \
     
    197201  (((x) & BIT (2)) == BIT (2))
    198202
    199 #define IS_ENABLE_BOOT_FILE_NAME(x) \
     203#define IS_DISABLE_PROMPT_MENU(x) \
    200204  (((x) & BIT (3)) == BIT (3))
    201205
     
    257261} PXEBC_DHCP4_OPTION_ENTRY;
    258262
     263#pragma pack(1)
    259264typedef struct {
    260265  UINT16            Type;
     
    273278  UINT8             Prompt[1];
    274279} PXEBC_MENU_PROMPT;
     280#pragma pack()
    275281
    276282typedef struct {
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c

    r48674 r58459  
    22  Functions implementation related with DHCPv6 for UefiPxeBc Driver.
    33
    4   Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    12611261  EFI_EVENT                        MappedEvt;
    12621262  EFI_STATUS                       Status;
     1263  UINT64                           DadTriggerTime;
     1264  EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS    DadXmits;
    12631265
    12641266  Status     = EFI_SUCCESS;
     
    13011303    //
    13021304    Private->Ip6Policy = PXEBC_IP6_POLICY_MAX;
     1305    goto ON_EXIT;
     1306  }
     1307
     1308  //
     1309  // Get Duplicate Address Detection Transmits count.
     1310  //
     1311  DataSize = sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS);
     1312  Status = Ip6Cfg->GetData (
     1313                     Ip6Cfg,
     1314                     Ip6ConfigDataTypeDupAddrDetectTransmits,
     1315                     &DataSize,
     1316                     &DadXmits
     1317                     );
     1318  if (EFI_ERROR (Status)) {
    13031319    goto ON_EXIT;
    13041320  }
     
    13551371  //
    13561372  Status = EFI_NO_MAPPING;
    1357   gBS->SetTimer (TimeOutEvt, TimerRelative, PXEBC_DHCP6_MAPPING_TIMEOUT);
     1373  DadTriggerTime = TICKS_PER_SECOND * DadXmits.DupAddrDetectTransmits + PXEBC_DAD_ADDITIONAL_DELAY;
     1374  gBS->SetTimer (TimeOutEvt, TimerRelative, DadTriggerTime);
    13581375
    13591376  while (EFI_ERROR (gBS->CheckEvent (TimeOutEvt))) {
     
    16991716  UINT32                           OptCount;
    17001717  EFI_STATUS                       Status;
     1718  EFI_IP6_CONFIG_PROTOCOL          *Ip6Cfg;
     1719  EFI_STATUS                       TimerStatus;
     1720  EFI_EVENT                        Timer;
     1721  UINT64                           GetMappingTimeOut;
     1722  UINTN                            DataSize;
     1723  EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS    DadXmits;
    17011724
    17021725  Status     = EFI_SUCCESS;
    17031726  PxeMode    = Private->PxeBc.Mode;
     1727  Ip6Cfg     = Private->Ip6Cfg;
     1728  Timer      = NULL;
    17041729
    17051730  //
     
    17241749  Config.RapidCommit           = FALSE;
    17251750  Config.ReconfigureAccept     = FALSE;
    1726   Config.IaDescriptor.IaId     = 1;
     1751  Config.IaDescriptor.IaId     = Private->IaId;
    17271752  Config.IaDescriptor.Type     = EFI_DHCP6_IA_TYPE_NA;
    17281753  Config.SolicitRetransmission = Retransmit;
     
    17361761  //
    17371762  Status = Dhcp6->Configure (Dhcp6, &Config);
    1738   if (EFI_ERROR (Status)) {
    1739     FreePool (Retransmit);
     1763  FreePool (Retransmit);
     1764  if (EFI_ERROR (Status)) {
    17401765    return Status;
    17411766  }
     
    17551780  //
    17561781  Status = Dhcp6->Start (Dhcp6);
     1782  if (Status == EFI_NO_MAPPING) {
     1783    //
     1784    // IP6 Linklocal address is not available for use, so stop current Dhcp process
     1785    // and wait for duplicate address detection to finish.
     1786    //
     1787    Dhcp6->Stop (Dhcp6);
     1788
     1789    //
     1790    // Get Duplicate Address Detection Transmits count.
     1791    //
     1792    DataSize = sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS);
     1793    Status = Ip6Cfg->GetData (
     1794                       Ip6Cfg,
     1795                       Ip6ConfigDataTypeDupAddrDetectTransmits,
     1796                       &DataSize,
     1797                       &DadXmits
     1798                       );
     1799    if (EFI_ERROR (Status)) {
     1800      Dhcp6->Configure (Dhcp6, NULL);
     1801      return Status;
     1802    }
     1803
     1804    Status = gBS->CreateEvent (EVT_TIMER, TPL_CALLBACK, NULL, NULL, &Timer);
     1805    if (EFI_ERROR (Status)) {
     1806      Dhcp6->Configure (Dhcp6, NULL);
     1807      return Status;
     1808    }
     1809
     1810    GetMappingTimeOut = TICKS_PER_SECOND * DadXmits.DupAddrDetectTransmits + PXEBC_DAD_ADDITIONAL_DELAY;
     1811    Status = gBS->SetTimer (Timer, TimerRelative, GetMappingTimeOut);
     1812    if (EFI_ERROR (Status)) {
     1813      gBS->CloseEvent (Timer);
     1814      Dhcp6->Configure (Dhcp6, NULL);
     1815      return Status;
     1816    }
     1817
     1818    do {
     1819     
     1820      TimerStatus = gBS->CheckEvent (Timer);
     1821      if (!EFI_ERROR (TimerStatus)) {
     1822        Status = Dhcp6->Start (Dhcp6);
     1823      }
     1824    } while (TimerStatus == EFI_NOT_READY);
     1825   
     1826    gBS->CloseEvent (Timer);
     1827  }
    17571828  if (EFI_ERROR (Status)) {
    17581829    if (Status == EFI_ICMP_ERROR) {
     
    17821853  }
    17831854
    1784   Status = PxeBcFlushStaionIp (Private, &Private->StationIp, NULL);
     1855  Status = PxeBcFlushStationIp (Private, &Private->StationIp, NULL);
    17851856  if (EFI_ERROR (Status)) {
    17861857    PxeBcUnregisterIp6Address (Private);
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.h

    r48674 r58459  
    22  Functions declaration related with DHCPv6 for UefiPxeBc Driver.
    33
    4   Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    2020#define PXEBC_DHCP6_OPTION_MAX_SIZE       312
    2121#define PXEBC_DHCP6_PACKET_MAX_SIZE       1472
    22 #define PXEBC_DHCP6_MAPPING_TIMEOUT       50000000   // 5 seconds, unit is 10nanosecond.
    2322#define PXEBC_IP6_POLICY_MAX              0xff
    2423
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c

    r48674 r58459  
    22  Driver Binding functions implementationfor for UefiPxeBc Driver.
    33
    4   Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    1717
    1818
    19 EFI_DRIVER_BINDING_PROTOCOL gPxeBcDriverBinding = {
    20   PxeBcDriverBindingSupported,
    21   PxeBcDriverBindingStart,
    22   PxeBcDriverBindingStop,
     19EFI_DRIVER_BINDING_PROTOCOL gPxeBcIp4DriverBinding = {
     20  PxeBcIp4DriverBindingSupported,
     21  PxeBcIp4DriverBindingStart,
     22  PxeBcIp4DriverBindingStop,
     23  0xa,
     24  NULL,
     25  NULL
     26};
     27
     28EFI_DRIVER_BINDING_PROTOCOL gPxeBcIp6DriverBinding = {
     29  PxeBcIp6DriverBindingSupported,
     30  PxeBcIp6DriverBindingStart,
     31  PxeBcIp6DriverBindingStop,
    2332  0xa,
    2433  NULL,
     
    780789  PXEBC_PRIVATE_PROTOCOL          *Id;
    781790  EFI_SIMPLE_NETWORK_PROTOCOL     *Snp;
     791  UINTN                           Index;
    782792
    783793  if (Private->Ip6Nic != NULL) {
     
    820830  if (EFI_ERROR (Status)) {
    821831    goto ON_ERROR;
     832  }
     833
     834  //
     835  // Generate a random IAID for the Dhcp6 assigned address.
     836  //
     837  Private->IaId = NET_RANDOM (NetRandomInitSeed ());
     838  if (Private->Snp != NULL) {
     839    for (Index = 0; Index < Private->Snp->Mode->HwAddressSize; Index++) {
     840      Private->IaId |= (Private->Snp->Mode->CurrentAddress.Addr[Index] << ((Index << 3) & 31));
     841    } 
    822842  }
    823843
     
    10791099  )
    10801100{
    1081   return EfiLibInstallDriverBindingComponentName2 (
     1101  EFI_STATUS  Status;
     1102
     1103  Status = EfiLibInstallDriverBindingComponentName2 (
     1104             ImageHandle,
     1105             SystemTable,
     1106             &gPxeBcIp4DriverBinding,
     1107             ImageHandle,
     1108             &gPxeBcComponentName,
     1109             &gPxeBcComponentName2
     1110             );
     1111  if (EFI_ERROR (Status)) {
     1112    return Status;
     1113  }
     1114
     1115  Status = EfiLibInstallDriverBindingComponentName2 (
     1116             ImageHandle,
     1117             SystemTable,
     1118             &gPxeBcIp6DriverBinding,
     1119             NULL,
     1120             &gPxeBcComponentName,
     1121             &gPxeBcComponentName2
     1122             );
     1123  if (EFI_ERROR (Status)) {
     1124    gBS->UninstallMultipleProtocolInterfaces (
    10821125           ImageHandle,
    1083            SystemTable,
    1084            &gPxeBcDriverBinding,
    1085            ImageHandle,
     1126           &gEfiDriverBindingProtocolGuid,
     1127           &gPxeBcIp4DriverBinding,
     1128           &gEfiComponentName2ProtocolGuid,
     1129           &gPxeBcComponentName2,
     1130           &gEfiComponentNameProtocolGuid,
    10861131           &gPxeBcComponentName,
    1087            &gPxeBcComponentName2
     1132           NULL
    10881133           );
     1134  }
     1135
     1136  return Status;
    10891137}
    10901138
    1091 
    10921139/**
    1093   Test to see if this driver supports ControllerHandle. This service
    1094   is called by the EFI boot service ConnectController(). In
    1095   order to make drivers as small as possible, there are a few calling
    1096   restrictions for this service. ConnectController() must
    1097   follow these calling restrictions. If any other agent wishes to call
    1098   Supported() it must also follow these calling restrictions.
     1140  Test to see if this driver supports ControllerHandle. This is the worker function for
     1141  PxeBcIp4(6)DriverBindingSupported.
    10991142
    11001143  @param[in]  This                The pointer to the driver binding protocol.
     
    11021145  @param[in]  RemainingDevicePath Optional parameter used to pick a specific child
    11031146                                  device to be started.
    1104 
     1147  @param[in]  IpVersion           IP_VERSION_4 or IP_VERSION_6.
     1148 
    11051149  @retval EFI_SUCCESS         This driver supports this device.
    11061150  @retval EFI_UNSUPPORTED     This driver does not support this device.
     
    11091153EFI_STATUS
    11101154EFIAPI
    1111 PxeBcDriverBindingSupported (
     1155PxeBcSupported (
    11121156  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
    11131157  IN EFI_HANDLE                   ControllerHandle,
    1114   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
     1158  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL,
     1159  IN UINT8                        IpVersion
    11151160  )
    11161161{
    1117   EFI_STATUS                      Ip4Status;
    1118   EFI_STATUS                      Ip6Status;
    1119 
    1120   //
    1121   // Try to open the Mtftp4 and Dhcp4 protocol to test whether IPv4 stack is ready.
    1122   //
    1123   Ip4Status = gBS->OpenProtocol (
     1162  EFI_STATUS                      Status;
     1163  EFI_GUID                        *DhcpServiceBindingGuid;
     1164  EFI_GUID                        *MtftpServiceBindingGuid;
     1165 
     1166  if (IpVersion == IP_VERSION_4) {
     1167    DhcpServiceBindingGuid  = &gEfiDhcp4ServiceBindingProtocolGuid;
     1168    MtftpServiceBindingGuid = &gEfiMtftp4ServiceBindingProtocolGuid;
     1169  } else {
     1170    DhcpServiceBindingGuid  = &gEfiDhcp6ServiceBindingProtocolGuid;
     1171    MtftpServiceBindingGuid = &gEfiMtftp6ServiceBindingProtocolGuid;
     1172  }
     1173
     1174  //
     1175  // Try to open the Mtftp and Dhcp protocol to test whether IP stack is ready.
     1176  //
     1177  Status = gBS->OpenProtocol (
    11241178                     ControllerHandle,
    1125                      &gEfiDhcp4ServiceBindingProtocolGuid,
     1179                     DhcpServiceBindingGuid,
    11261180                     NULL,
    11271181                     This->DriverBindingHandle,
     
    11291183                     EFI_OPEN_PROTOCOL_TEST_PROTOCOL
    11301184                     );
    1131   if (!EFI_ERROR (Ip4Status)) {
    1132     Ip4Status = gBS->OpenProtocol (
     1185  if (!EFI_ERROR (Status)) {
     1186    Status = gBS->OpenProtocol (
    11331187                       ControllerHandle,
    1134                        &gEfiMtftp4ServiceBindingProtocolGuid,
     1188                       MtftpServiceBindingGuid,
    11351189                       NULL,
    11361190                       This->DriverBindingHandle,
     
    11411195
    11421196  //
    1143   // Try to open the Mtftp6 and Dhcp6 protocol to test whether IPv4 stack is ready.
    1144   //
    1145   Ip6Status = gBS->OpenProtocol (
    1146                      ControllerHandle,
    1147                      &gEfiDhcp6ServiceBindingProtocolGuid,
    1148                      NULL,
    1149                      This->DriverBindingHandle,
    1150                      ControllerHandle,
    1151                      EFI_OPEN_PROTOCOL_TEST_PROTOCOL
    1152                      );
    1153   if (!EFI_ERROR (Ip6Status)) {
    1154     Ip6Status = gBS->OpenProtocol (
    1155                        ControllerHandle,
    1156                        &gEfiMtftp6ServiceBindingProtocolGuid,
    1157                        NULL,
    1158                        This->DriverBindingHandle,
    1159                        ControllerHandle,
    1160                        EFI_OPEN_PROTOCOL_TEST_PROTOCOL
    1161                        );
    1162   }
    1163 
    1164   //
    1165   // It's unsupported case if both stack are not ready.
    1166   //
    1167   if (EFI_ERROR (Ip4Status) && EFI_ERROR (Ip6Status)) {
     1197  // It's unsupported case if IP stack are not ready.
     1198  //
     1199  if (EFI_ERROR (Status)) {
    11681200    return EFI_UNSUPPORTED;
    11691201  }
     
    11721204}
    11731205
    1174 
    11751206/**
    1176   Start this driver on ControllerHandle. This service is called by the
    1177   EFI boot service ConnectController(). In order to make
    1178   drivers as small as possible, there are a few calling restrictions for
    1179   this service. ConnectController() must follow these
    1180   calling restrictions. If any other agent wishes to call Start() it
    1181   must also follow these calling restrictions.
     1207  Start this driver on ControllerHandle. This is the worker function for
     1208  PxeBcIp4(6)DriverBindingStart.
    11821209
    11831210  @param[in]  This                 The pointer to the driver binding protocol.
     
    11851212  @param[in]  RemainingDevicePath  Optional parameter used to pick a specific child
    11861213                                   device to be started.
     1214  @param[in]  IpVersion            IP_VERSION_4 or IP_VERSION_6.
     1215
    11871216
    11881217  @retval EFI_SUCCESS          This driver is installed to ControllerHandle.
     
    11931222EFI_STATUS
    11941223EFIAPI
    1195 PxeBcDriverBindingStart (
     1224PxeBcStart (
    11961225  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
    11971226  IN EFI_HANDLE                   ControllerHandle,
    1198   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
     1227  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL,
     1228  IN UINT8                        IpVersion
    11991229  )
    12001230{
    12011231  PXEBC_PRIVATE_DATA              *Private;
    12021232  EFI_STATUS                      Status;
    1203   EFI_STATUS                      Ip4Status;
    1204   EFI_STATUS                      Ip6Status;
    12051233  PXEBC_PRIVATE_PROTOCOL          *Id;
    1206 
     1234  BOOLEAN                         FirstStart;
     1235
     1236  FirstStart = FALSE;
    12071237  Status = gBS->OpenProtocol (
    12081238                  ControllerHandle,
     
    12191249    Private = PXEBC_PRIVATE_DATA_FROM_ID (Id);
    12201250  } else {
     1251    FirstStart = TRUE;
    12211252    //
    12221253    // If the driver has not been started yet, it should do initialization.
     
    12951326  }
    12961327
    1297   //
    1298   // Try to create virtual NIC handle for IPv4.
    1299   //
    1300   Ip4Status = PxeBcCreateIp4Children (This, ControllerHandle, Private);
    1301 
    1302   //
    1303   // Try to create virtual NIC handle for IPv6.
    1304   //
    1305   Ip6Status = PxeBcCreateIp6Children (This, ControllerHandle, Private);
    1306 
    1307   if (EFI_ERROR (Ip4Status) && EFI_ERROR (Ip6Status)) {
     1328  if (IpVersion == IP_VERSION_4) {
     1329    //
     1330    // Try to create virtual NIC handle for IPv4.
     1331    //
     1332    Status = PxeBcCreateIp4Children (This, ControllerHandle, Private);
     1333  } else {
     1334    //
     1335    // Try to create virtual NIC handle for IPv6.
     1336    //
     1337    Status = PxeBcCreateIp6Children (This, ControllerHandle, Private);
     1338  }
     1339  if (EFI_ERROR (Status)) {
    13081340    //
    13091341    // Failed to start PXE driver if IPv4 and IPv6 stack are both not available.
     
    13161348
    13171349ON_ERROR:
    1318   gBS->UninstallProtocolInterface (
    1319          ControllerHandle,
    1320          &gEfiCallerIdGuid,
    1321          &Private->Id
    1322          );
    1323   PxeBcDestroyIp4Children (This, Private);
    1324   PxeBcDestroyIp6Children (This, Private);
    1325   FreePool (Private);
     1350  if (FirstStart) {
     1351    gBS->UninstallProtocolInterface (
     1352           ControllerHandle,
     1353           &gEfiCallerIdGuid,
     1354           &Private->Id
     1355           );
     1356  }
     1357
     1358  if (IpVersion == IP_VERSION_4) {
     1359    PxeBcDestroyIp4Children (This, Private);
     1360  } else {
     1361    PxeBcDestroyIp6Children (This, Private);
     1362  }
     1363
     1364  if (FirstStart && Private != NULL) {
     1365    FreePool (Private);
     1366  }
    13261367
    13271368  return Status;
     
    13301371
    13311372/**
    1332   Stop this driver on ControllerHandle. This service is called by the
    1333   EFI boot service DisconnectController(). In order to
    1334   make drivers as small as possible, there are a few calling
    1335   restrictions for this service. DisconnectController()
    1336   must follow these calling restrictions. If any other agent wishes
    1337   to call Stop() it must also follow these calling restrictions.
     1373  Stop this driver on ControllerHandle. This is the worker function for
     1374  PxeBcIp4(6)DriverBindingStop.
    13381375
    13391376  @param[in]  This              Protocol instance pointer.
     
    13421379                                children is zero stop the entire bus driver.
    13431380  @param[in]  ChildHandleBuffer List of Child Handles to Stop.
     1381  @param[in]  IpVersion         IP_VERSION_4 or IP_VERSION_6.
    13441382
    13451383  @retval EFI_SUCCESS           This driver was removed ControllerHandle.
     
    13501388EFI_STATUS
    13511389EFIAPI
    1352 PxeBcDriverBindingStop (
     1390PxeBcStop (
    13531391  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
    13541392  IN EFI_HANDLE                   ControllerHandle,
    13551393  IN UINTN                        NumberOfChildren,
    1356   IN EFI_HANDLE                   *ChildHandleBuffer
     1394  IN EFI_HANDLE                   *ChildHandleBuffer,
     1395  IN UINT8                        IpVersion
    13571396  )
    13581397{
     
    13841423    // Get the Nic handle by any pass-over service child handle.
    13851424    //
    1386     NicHandle = PxeBcGetNicByIp4Children (ControllerHandle);
     1425    if (IpVersion == IP_VERSION_4) {
     1426      NicHandle = PxeBcGetNicByIp4Children (ControllerHandle);
     1427    } else {
     1428      NicHandle = PxeBcGetNicByIp6Children (ControllerHandle);
     1429    }
    13871430    if (NicHandle == NULL) {
    1388       NicHandle = PxeBcGetNicByIp6Children (ControllerHandle);
    1389       if (NicHandle == NULL) {
    1390         return EFI_DEVICE_ERROR;
    1391       } else {
    1392         IsIpv6 = TRUE;
    1393       }
     1431      return EFI_SUCCESS;
    13941432    }
    13951433
     
    14291467    Private    = VirtualNic->Private;
    14301468    NicHandle  = Private->Controller;
    1431 
    1432     if (Private->Ip6Nic == VirtualNic) {
    1433       IsIpv6   = TRUE;
    1434     }
    14351469  }
    14361470
     
    14441478
    14451479
    1446   if (Private->Ip4Nic != NULL && !IsIpv6) {
     1480  if (Private->Ip4Nic != NULL && IpVersion == IP_VERSION_4) {
    14471481    PxeBcDestroyIp4Children (This, Private);
    14481482  }
    14491483
    1450   if (Private->Ip6Nic != NULL && IsIpv6) {
     1484  if (Private->Ip6Nic != NULL && IpVersion == IP_VERSION_6) {
    14511485    PxeBcDestroyIp6Children (This, Private);
    14521486  }
     
    14631497  return EFI_SUCCESS;
    14641498}
     1499
     1500/**
     1501  Test to see if this driver supports ControllerHandle. This service
     1502  is called by the EFI boot service ConnectController(). In
     1503  order to make drivers as small as possible, there are a few calling
     1504  restrictions for this service. ConnectController() must
     1505  follow these calling restrictions. If any other agent wishes to call
     1506  Supported() it must also follow these calling restrictions.
     1507
     1508  @param[in]  This                The pointer to the driver binding protocol.
     1509  @param[in]  ControllerHandle    The handle of device to be tested.
     1510  @param[in]  RemainingDevicePath Optional parameter used to pick a specific child
     1511                                  device to be started.
     1512
     1513  @retval EFI_SUCCESS         This driver supports this device.
     1514  @retval EFI_UNSUPPORTED     This driver does not support this device.
     1515
     1516**/
     1517EFI_STATUS
     1518EFIAPI
     1519PxeBcIp4DriverBindingSupported (
     1520  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     1521  IN EFI_HANDLE                   ControllerHandle,
     1522  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
     1523  )
     1524{
     1525  return PxeBcSupported (
     1526           This,
     1527           ControllerHandle,
     1528           RemainingDevicePath,
     1529           IP_VERSION_4
     1530           );
     1531}
     1532
     1533/**
     1534  Start this driver on ControllerHandle. This service is called by the
     1535  EFI boot service ConnectController(). In order to make
     1536  drivers as small as possible, there are a few calling restrictions for
     1537  this service. ConnectController() must follow these
     1538  calling restrictions. If any other agent wishes to call Start() it
     1539  must also follow these calling restrictions.
     1540
     1541  @param[in]  This                 The pointer to the driver binding protocol.
     1542  @param[in]  ControllerHandle     The handle of device to be started.
     1543  @param[in]  RemainingDevicePath  Optional parameter used to pick a specific child
     1544                                   device to be started.
     1545
     1546  @retval EFI_SUCCESS          This driver is installed to ControllerHandle.
     1547  @retval EFI_ALREADY_STARTED  This driver is already running on ControllerHandle.
     1548  @retval other                This driver does not support this device.
     1549
     1550**/
     1551EFI_STATUS
     1552EFIAPI
     1553PxeBcIp4DriverBindingStart (
     1554  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     1555  IN EFI_HANDLE                   ControllerHandle,
     1556  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
     1557  )
     1558{
     1559  return PxeBcStart (
     1560           This,
     1561           ControllerHandle,
     1562           RemainingDevicePath,
     1563           IP_VERSION_4
     1564           );
     1565}
     1566
     1567/**
     1568  Stop this driver on ControllerHandle. This service is called by the
     1569  EFI boot service DisconnectController(). In order to
     1570  make drivers as small as possible, there are a few calling
     1571  restrictions for this service. DisconnectController()
     1572  must follow these calling restrictions. If any other agent wishes
     1573  to call Stop() it must also follow these calling restrictions.
     1574
     1575  @param[in]  This              Protocol instance pointer.
     1576  @param[in]  ControllerHandle  Handle of device to stop driver on
     1577  @param[in]  NumberOfChildren  Number of Handles in ChildHandleBuffer. If number of
     1578                                children is zero stop the entire bus driver.
     1579  @param[in]  ChildHandleBuffer List of Child Handles to Stop.
     1580
     1581  @retval EFI_SUCCESS           This driver is removed ControllerHandle
     1582  @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred.
     1583  @retval Others                This driver was not removed from this device.
     1584
     1585**/
     1586EFI_STATUS
     1587EFIAPI
     1588PxeBcIp4DriverBindingStop (
     1589  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     1590  IN EFI_HANDLE                   ControllerHandle,
     1591  IN UINTN                        NumberOfChildren,
     1592  IN EFI_HANDLE                   *ChildHandleBuffer
     1593  )
     1594{
     1595  return PxeBcStop (
     1596           This,
     1597           ControllerHandle,
     1598           NumberOfChildren,
     1599           ChildHandleBuffer,
     1600           IP_VERSION_4
     1601           );
     1602}
     1603
     1604/**
     1605  Test to see if this driver supports ControllerHandle. This service
     1606  is called by the EFI boot service ConnectController(). In
     1607  order to make drivers as small as possible, there are a few calling
     1608  restrictions for this service. ConnectController() must
     1609  follow these calling restrictions. If any other agent wishes to call
     1610  Supported() it must also follow these calling restrictions.
     1611
     1612  @param[in]  This                The pointer to the driver binding protocol.
     1613  @param[in]  ControllerHandle    The handle of device to be tested.
     1614  @param[in]  RemainingDevicePath Optional parameter use to pick a specific child
     1615                                  device to be started.
     1616
     1617  @retval EFI_SUCCESS         This driver supports this device.
     1618  @retval EFI_UNSUPPORTED     This driver does not support this device.
     1619
     1620**/
     1621EFI_STATUS
     1622EFIAPI
     1623PxeBcIp6DriverBindingSupported (
     1624  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     1625  IN EFI_HANDLE                   ControllerHandle,
     1626  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
     1627  )
     1628{
     1629  return PxeBcSupported (
     1630           This,
     1631           ControllerHandle,
     1632           RemainingDevicePath,
     1633           IP_VERSION_6
     1634           );
     1635}
     1636
     1637/**
     1638  Start this driver on ControllerHandle. This service is called by the
     1639  EFI boot service ConnectController(). In order to make
     1640  drivers as small as possible, there are a few calling restrictions for
     1641  this service. ConnectController() must follow these
     1642  calling restrictions. If any other agent wishes to call Start() it
     1643  must also follow these calling restrictions.
     1644
     1645  @param[in]  This                 The pointer to the driver binding protocol.
     1646  @param[in]  ControllerHandle     The handle of device to be started.
     1647  @param[in]  RemainingDevicePath  Optional parameter used to pick a specific child
     1648                                   device to be started.
     1649
     1650  @retval EFI_SUCCESS          This driver is installed to ControllerHandle.
     1651  @retval EFI_ALREADY_STARTED  This driver is already running on ControllerHandle.
     1652  @retval other                This driver does not support this device.
     1653
     1654**/
     1655EFI_STATUS
     1656EFIAPI
     1657PxeBcIp6DriverBindingStart (
     1658  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     1659  IN EFI_HANDLE                   ControllerHandle,
     1660  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
     1661  )
     1662{
     1663  return PxeBcStart (
     1664           This,
     1665           ControllerHandle,
     1666           RemainingDevicePath,
     1667           IP_VERSION_6
     1668           );
     1669}
     1670
     1671/**
     1672  Stop this driver on ControllerHandle. This service is called by the
     1673  EFI boot service DisconnectController(). In order to
     1674  make drivers as small as possible, there are a few calling
     1675  restrictions for this service. DisconnectController()
     1676  must follow these calling restrictions. If any other agent wishes
     1677  to call Stop() it must also follow these calling restrictions.
     1678
     1679  @param[in]  This              Protocol instance pointer.
     1680  @param[in]  ControllerHandle  Handle of device to stop driver on
     1681  @param[in]  NumberOfChildren  Number of Handles in ChildHandleBuffer. If number of
     1682                                children is zero stop the entire bus driver.
     1683  @param[in]  ChildHandleBuffer List of Child Handles to Stop.
     1684
     1685  @retval EFI_SUCCESS           This driver is removed ControllerHandle
     1686  @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred.
     1687  @retval Others                This driver was not removed from this device.
     1688
     1689**/
     1690EFI_STATUS
     1691EFIAPI
     1692PxeBcIp6DriverBindingStop (
     1693  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     1694  IN EFI_HANDLE                   ControllerHandle,
     1695  IN UINTN                        NumberOfChildren,
     1696  IN EFI_HANDLE                   *ChildHandleBuffer
     1697  )
     1698{
     1699  return PxeBcStop (
     1700           This,
     1701           ControllerHandle,
     1702           NumberOfChildren,
     1703           ChildHandleBuffer,
     1704           IP_VERSION_6
     1705           );
     1706}
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.h

    r48674 r58459  
    22  Driver Binding functions declaration for UefiPxeBc Driver.
    33
    4   Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    3939EFI_STATUS
    4040EFIAPI
    41 PxeBcDriverBindingSupported (
     41PxeBcIp4DriverBindingSupported (
    4242  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
    4343  IN EFI_HANDLE                   ControllerHandle,
    4444  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
    4545  );
    46 
    4746
    4847/**
     
    6665EFI_STATUS
    6766EFIAPI
    68 PxeBcDriverBindingStart (
     67PxeBcIp4DriverBindingStart (
    6968  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
    7069  IN EFI_HANDLE                   ControllerHandle,
     
    9493EFI_STATUS
    9594EFIAPI
    96 PxeBcDriverBindingStop (
     95PxeBcIp4DriverBindingStop (
    9796  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
    9897  IN EFI_HANDLE                   ControllerHandle,
     
    101100  );
    102101
     102/**
     103  Test to see if this driver supports ControllerHandle. This service
     104  is called by the EFI boot service ConnectController(). In
     105  order to make drivers as small as possible, there are a few calling
     106  restrictions for this service. ConnectController() must
     107  follow these calling restrictions. If any other agent wishes to call
     108  Supported() it must also follow these calling restrictions.
     109
     110  @param[in]  This                The pointer to the driver binding protocol.
     111  @param[in]  ControllerHandle    The handle of device to be tested.
     112  @param[in]  RemainingDevicePath Optional parameter use to pick a specific child
     113                                  device to be started.
     114
     115  @retval EFI_SUCCESS         This driver supports this device.
     116  @retval EFI_UNSUPPORTED     This driver does not support this device.
     117
     118**/
     119EFI_STATUS
     120EFIAPI
     121PxeBcIp6DriverBindingSupported (
     122  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     123  IN EFI_HANDLE                   ControllerHandle,
     124  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
     125  );
     126
     127/**
     128  Start this driver on ControllerHandle. This service is called by the
     129  EFI boot service ConnectController(). In order to make
     130  drivers as small as possible, there are a few calling restrictions for
     131  this service. ConnectController() must follow these
     132  calling restrictions. If any other agent wishes to call Start() it
     133  must also follow these calling restrictions.
     134
     135  @param[in]  This                 The pointer to the driver binding protocol.
     136  @param[in]  ControllerHandle     The handle of device to be started.
     137  @param[in]  RemainingDevicePath  Optional parameter used to pick a specific child
     138                                   device to be started.
     139
     140  @retval EFI_SUCCESS          This driver is installed to ControllerHandle.
     141  @retval EFI_ALREADY_STARTED  This driver is already running on ControllerHandle.
     142  @retval other                This driver does not support this device.
     143
     144**/
     145EFI_STATUS
     146EFIAPI
     147PxeBcIp6DriverBindingStart (
     148  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     149  IN EFI_HANDLE                   ControllerHandle,
     150  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
     151  );
     152
     153/**
     154  Stop this driver on ControllerHandle. This service is called by the
     155  EFI boot service DisconnectController(). In order to
     156  make drivers as small as possible, there are a few calling
     157  restrictions for this service. DisconnectController()
     158  must follow these calling restrictions. If any other agent wishes
     159  to call Stop() it must also follow these calling restrictions.
     160
     161  @param[in]  This              Protocol instance pointer.
     162  @param[in]  ControllerHandle  Handle of device to stop driver on
     163  @param[in]  NumberOfChildren  Number of Handles in ChildHandleBuffer. If number of
     164                                children is zero stop the entire bus driver.
     165  @param[in]  ChildHandleBuffer List of Child Handles to Stop.
     166
     167  @retval EFI_SUCCESS           This driver is removed ControllerHandle
     168  @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred.
     169  @retval Others                This driver was not removed from this device.
     170
     171**/
     172EFI_STATUS
     173EFIAPI
     174PxeBcIp6DriverBindingStop (
     175  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
     176  IN EFI_HANDLE                   ControllerHandle,
     177  IN UINTN                        NumberOfChildren,
     178  IN EFI_HANDLE                   *ChildHandleBuffer
     179  );
    103180#endif
    104181
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c

    r48674 r58459  
    22  This implementation of EFI_PXE_BASE_CODE_PROTOCOL and EFI_LOAD_FILE_PROTOCOL.
    33
    4   Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    346346  Private->SolicitTimes = 0;
    347347  Private->ElapsedTime  = 0;
     348  ZeroMem (&Private->StationIp, sizeof (EFI_IP_ADDRESS));
     349  ZeroMem (&Private->SubnetMask, sizeof (EFI_IP_ADDRESS));
     350  ZeroMem (&Private->GatewayIp, sizeof (EFI_IP_ADDRESS));
     351  ZeroMem (&Private->ServerIp, sizeof (EFI_IP_ADDRESS));
    348352
    349353  //
     
    429433    //
    430434    Status = PxeBcDhcp6Sarr (Private, Private->Dhcp6);
    431 
    432     if (EFI_ERROR (Status)) {
    433       goto ON_EXIT;
    434     }
    435435  } else {
    436436
     
    444444    //
    445445    Status = PxeBcDhcp4Dora (Private, Private->Dhcp4);
    446 
    447     if (EFI_ERROR (Status)) {
    448       goto ON_EXIT;
    449     }
    450   }
    451  
    452 ON_EXIT:
     446  }
     447
     448  //
     449  // Reconfigure the UDP instance with the default configuration.
     450  //
    453451  if (Mode->UsingIpv6) {
    454452    Private->Udp6Read->Configure (Private->Udp6Read, &Private->Udp6CfgData);
     
    530528  EFI_STATUS                      Status;
    531529  EFI_PXE_BASE_CODE_IP_FILTER     IpFilter;
     530  EFI_PXE_BASE_CODE_DISCOVER_INFO *NewCreatedInfo;
    532531
    533532  if (This == NULL) {
     
    542541  Status                  = EFI_DEVICE_ERROR;
    543542  Private->Function       = EFI_PXE_BASE_CODE_FUNCTION_DISCOVER;
     543  NewCreatedInfo          = NULL;
    544544
    545545  if (!Mode->Started) {
     
    571571  // There are 3 methods to get the information for discover.
    572572  //
     573  ZeroMem (&DefaultInfo, sizeof (EFI_PXE_BASE_CODE_DISCOVER_INFO));
    573574  if (*Layer != EFI_PXE_BASE_CODE_BOOT_LAYER_INITIAL) {
    574575    //
     
    595596    // 2. Extract the discover information from the cached packets if unspecified.
    596597    //
    597     Info  = &DefaultInfo;
    598     Status = PxeBcExtractDiscoverInfo (Private, Type, Info, &BootSvrEntry, &SrvList);
     598    NewCreatedInfo = &DefaultInfo;
     599    Status = PxeBcExtractDiscoverInfo (Private, Type, &NewCreatedInfo, &BootSvrEntry, &SrvList);
    599600    if (EFI_ERROR (Status)) {
    600601      goto ON_EXIT;
    601602    }
    602 
     603    ASSERT (NewCreatedInfo != NULL);
     604    Info = NewCreatedInfo;
    603605  } else {
    604606    //
     
    616618        //
    617619        // It's invalid if the first server doesn't accecpt any response
    618         // and meanwhile any of the rest servers accept any reponse.
     620        // but any of the other servers does accept any response.
    619621        //
    620622        Status = EFI_INVALID_PARAMETER;
     
    635637  Private->IsDoDiscover = TRUE;
    636638
    637   if (Info->UseUCast) {
    638     //
    639     // Do discover by unicast.
    640     //
    641     for (Index = 0; Index < Info->IpCnt; Index++) {
    642       if (BootSvrEntry == NULL) {
    643         CopyMem (&Private->ServerIp, &SrvList[Index].IpAddr, sizeof (EFI_IP_ADDRESS));
    644       } else {
    645         ASSERT (!Mode->UsingIpv6);
    646         ZeroMem (&Private->ServerIp, sizeof (EFI_IP_ADDRESS));
    647         CopyMem (&Private->ServerIp, &BootSvrEntry->IpAddr[Index], sizeof (EFI_IPv4_ADDRESS));
    648       }
    649 
    650       Status = PxeBcDiscoverBootServer (
    651                  Private,
    652                  Type,
    653                  Layer,
    654                  UseBis,
    655                  &SrvList[Index].IpAddr,
    656                  0,
    657                  NULL
    658                  );
    659     }
    660   } else if (Info->UseMCast) {
     639  if (Info->UseMCast) {
    661640    //
    662641    // Do discover by multicast.
     
    668647               UseBis,
    669648               &Info->ServerMCastIp,
    670                0,
    671                NULL
     649               Info->IpCnt,
     650               SrvList
    672651               );
    673652
     
    686665               SrvList
    687666               );
    688   }
    689 
    690   if (EFI_ERROR (Status)) {
    691     goto ON_EXIT;
    692   } else {
     667
     668  } else if (Info->UseUCast) {
     669    //
     670    // Do discover by unicast.
     671    //
     672    for (Index = 0; Index < Info->IpCnt; Index++) {
     673      if (BootSvrEntry == NULL) {
     674        CopyMem (&Private->ServerIp, &SrvList[Index].IpAddr, sizeof (EFI_IP_ADDRESS));
     675      } else {
     676        ASSERT (!Mode->UsingIpv6);
     677        ZeroMem (&Private->ServerIp, sizeof (EFI_IP_ADDRESS));
     678        CopyMem (&Private->ServerIp, &BootSvrEntry->IpAddr[Index], sizeof (EFI_IPv4_ADDRESS));
     679      }
     680
     681      Status = PxeBcDiscoverBootServer (
     682                 Private,
     683                 Type,
     684                 Layer,
     685                 UseBis,
     686                 &Private->ServerIp,
     687                 Info->IpCnt,
     688                 SrvList
     689                 );
     690      }
     691  }
     692
     693  if (!EFI_ERROR (Status)) {
    693694    //
    694695    // Parse the cached PXE reply packet, and store it into mode data if valid.
     
    699700        CopyMem (
    700701          &Mode->PxeReply.Dhcpv6,
    701           &Private->PxeReply.Dhcp6.Packet.Offer,
    702           Private->PxeReply.Dhcp6.Packet.Offer.Length
     702          &Private->PxeReply.Dhcp6.Packet.Ack.Dhcp6,
     703          Private->PxeReply.Dhcp6.Packet.Ack.Length
    703704          );
    704705        Mode->PxeReplyReceived = TRUE;
     
    710711        CopyMem (
    711712          &Mode->PxeReply.Dhcpv4,
    712           &Private->PxeReply.Dhcp4.Packet.Offer,
    713           Private->PxeReply.Dhcp4.Packet.Offer.Length
     713          &Private->PxeReply.Dhcp4.Packet.Ack.Dhcp4,
     714          Private->PxeReply.Dhcp4.Packet.Ack.Length
    714715          );
    715716        Mode->PxeReplyReceived = TRUE;
     
    721722ON_EXIT:
    722723
     724  if (NewCreatedInfo != NULL && NewCreatedInfo != &DefaultInfo) {
     725    FreePool (NewCreatedInfo);
     726  }
     727 
    723728  if (Mode->UsingIpv6) {
    724729    Private->Udp6Read->Configure (Private->Udp6Read, &Private->Udp6CfgData);
     
    958963  }
    959964
    960   if (EFI_ERROR (Status)) {
    961     goto ON_EXIT;
    962   }
    963  
    964 ON_EXIT:
     965  //
     966  // Reconfigure the UDP instance with the default configuration.
     967  //
    965968  if (Mode->UsingIpv6) {
    966969    Private->Udp6Read->Configure (Private->Udp6Read, &Private->Udp6CfgData);
     
    20232026  }
    20242027
    2025   Status = PxeBcFlushStaionIp (Private, NewStationIp, NewSubnetMask);
     2028  Status = PxeBcFlushStationIp (Private, NewStationIp, NewSubnetMask);
    20262029ON_EXIT:
    20272030  return Status;
     
    23422345  //
    23432346  Status = PxeBc->Start (PxeBc, UsingIpv6);
     2347  if (Status == EFI_ALREADY_STARTED && UsingIpv6 != PxeBc->Mode->UsingIpv6) {
     2348    //
     2349    // PxeBc protocol has already been started but not on the required IP version, restart it.
     2350    //
     2351    Status = PxeBc->Stop (PxeBc);
     2352    if (!EFI_ERROR (Status)) {
     2353      Status = PxeBc->Start (PxeBc, UsingIpv6);
     2354    }
     2355  }
    23442356  if (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED) {
    23452357    Status = PxeBcLoadBootFile (Private, BufferSize, Buffer);
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.h

    r48674 r58459  
    33  interfaces declaration.
    44
    5   Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
     5  Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>
    66
    77  This program and the accompanying materials
     
    6666#define PXEBC_DEFAULT_LIFETIME        50000    // 50 ms, unit is microsecond
    6767#define PXEBC_UDP_TIMEOUT             30000000 // 3 seconds, unit is 100nanosecond
     68#define PXEBC_DAD_ADDITIONAL_DELAY    30000000 // 3 seconds
    6869#define PXEBC_MTFTP_TIMEOUT           4
    6970#define PXEBC_MTFTP_RETRIES           6
     
    165166  EFI_IP_ADDRESS                            ServerIp;
    166167  UINT16                                    CurSrcPort;
     168  UINT32                                    IaId;
    167169
    168170  UINT32                                    Ip4MaxPacketSize;
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/UefiPxeBcDxe/PxeBcMtftp.c

    r48674 r58459  
    22  Functions implementation related with Mtftp for UefiPxeBc Driver.
    33
    4   Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    7070      PXE_MTFTP_ERROR_STRING_LENGTH
    7171      );
     72    Private->Mode.TftpError.ErrorString[PXE_MTFTP_ERROR_STRING_LENGTH - 1] = '\0';
    7273  }
    7374
     
    163164  Status = Mtftp6->GetInfo (
    164165                     Mtftp6,
    165                      FALSE,
     166                     NULL,
    166167                     Filename,
    167168                     NULL,
     
    183184        PXE_MTFTP_ERROR_STRING_LENGTH
    184185        );
     186      Private->Mode.TftpError.ErrorString[PXE_MTFTP_ERROR_STRING_LENGTH - 1] = '\0';
    185187    }
    186188    goto ON_ERROR;
     
    512514      PXE_MTFTP_ERROR_STRING_LENGTH
    513515      );
     516    Private->Mode.TftpError.ErrorString[PXE_MTFTP_ERROR_STRING_LENGTH - 1] = '\0';
    514517  }
    515518
     
    605608  Status = Mtftp4->GetInfo (
    606609                     Mtftp4,
    607                      FALSE,
     610                     NULL,
    608611                     Filename,
    609612                     NULL,
     
    625628        PXE_MTFTP_ERROR_STRING_LENGTH
    626629        );
     630      Private->Mode.TftpError.ErrorString[PXE_MTFTP_ERROR_STRING_LENGTH - 1] = '\0';
    627631    }
    628632    goto ON_ERROR;
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c

    r48674 r58459  
    22  Support functions implementation for UefiPxeBc Driver.
    33
    4   Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    2929**/
    3030EFI_STATUS
    31 PxeBcFlushStaionIp (
     31PxeBcFlushStationIp (
    3232  PXEBC_PRIVATE_DATA       *Private,
    3333  EFI_IP_ADDRESS           *StationIp,
     
    6060
    6161    Status = Private->Ip6->Receive (Private->Ip6, &Private->Icmp6Token);
    62     if (EFI_ERROR (Status)) {
    63       goto ON_EXIT;
    64     }
    65 
    6662  } else {
    6763    ASSERT (SubnetMask != NULL);
     
    8379
    8480    Status = Private->Ip4->Receive (Private->Ip4, &Private->IcmpToken);
    85     if (EFI_ERROR (Status)) {
    86       goto ON_EXIT;
    87     }
    88 
    8981  }
    9082
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.h

    r48674 r58459  
    22  Support functions declaration for UefiPxeBc Driver.
    33
    4   Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    3939**/
    4040EFI_STATUS
    41 PxeBcFlushStaionIp (
     41PxeBcFlushStationIp (
    4242  PXEBC_PRIVATE_DATA       *Private,
    4343  EFI_IP_ADDRESS           *StationIp,
     
    486486  );
    487487
     488/**
     489  Get the Nic handle using any child handle in the IPv4 stack.
     490
     491  @param[in]  ControllerHandle    Pointer to child handle over IPv4.
     492
     493  @return NicHandle               The pointer to the Nic handle.
     494
     495**/
     496EFI_HANDLE
     497PxeBcGetNicByIp4Children (
     498  IN EFI_HANDLE                 ControllerHandle
     499  );
     500
     501/**
     502  Get the Nic handle using any child handle in the IPv6 stack.
     503
     504  @param[in]  ControllerHandle    Pointer to child handle over IPv6.
     505
     506  @return NicHandle               The pointer to the Nic handle.
     507
     508**/
     509EFI_HANDLE
     510PxeBcGetNicByIp6Children (
     511  IN EFI_HANDLE                  ControllerHandle
     512  );
    488513#endif
  • trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf

    r48674 r58459  
    11## @file
    2 #  Component name for module PxeBc
     2#  Access PXE-compatible devices for network access and network booting.
     3
     4#  This driver provides PXE Base Code Protocol which is used to accessing
     5#  PXE-compatible device for network access or booting. It could work together
     6#  with an IPv4 stack, an IPv6 stack or both.
    37#
    4 #  Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
     8#
     9#  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
    510#
    611#  This program and the accompanying materials
     
    2227  ENTRY_POINT                    = PxeBcDriverEntryPoint
    2328  UNLOAD_IMAGE                   = NetLibDefaultUnload
     29  MODULE_UNI_FILE                = UefiPxeBcDxe.uni
     30
    2431#
    2532# The following information is for reference only and not required by the build tools.
     
    6471  PcdLib
    6572
    66 
    67 [Guids]
    68   gEfiSmbiosTableGuid
    69 
    70 
    7173[Protocols]
    72   gEfiDevicePathProtocolGuid
    73   gEfiNetworkInterfaceIdentifierProtocolGuid_31
    74   gEfiArpServiceBindingProtocolGuid
    75   gEfiArpProtocolGuid
    76   gEfiIp4ServiceBindingProtocolGuid
    77   gEfiIp4ProtocolGuid
    78   gEfiIp6ServiceBindingProtocolGuid
    79   gEfiIp6ProtocolGuid
    80   gEfiIp6ConfigProtocolGuid
    81   gEfiUdp4ServiceBindingProtocolGuid
    82   gEfiUdp4ProtocolGuid
    83   gEfiMtftp4ServiceBindingProtocolGuid
    84   gEfiMtftp4ProtocolGuid
    85   gEfiDhcp4ServiceBindingProtocolGuid
    86   gEfiDhcp4ProtocolGuid
    87   gEfiUdp6ServiceBindingProtocolGuid
    88   gEfiUdp6ProtocolGuid
    89   gEfiMtftp6ServiceBindingProtocolGuid
    90   gEfiMtftp6ProtocolGuid
    91   gEfiDhcp6ServiceBindingProtocolGuid
    92   gEfiDhcp6ProtocolGuid
    93   gEfiPxeBaseCodeCallbackProtocolGuid
    94   gEfiPxeBaseCodeProtocolGuid
    95   gEfiLoadFileProtocolGuid
     74  ## TO_START
     75  ## SOMETIMES_CONSUMES
     76  gEfiDevicePathProtocolGuid                           
     77  gEfiNetworkInterfaceIdentifierProtocolGuid_31        ## SOMETIMES_CONSUMES
     78  gEfiArpServiceBindingProtocolGuid                    ## TO_START
     79  gEfiArpProtocolGuid                                  ## TO_START
     80  gEfiIp4ServiceBindingProtocolGuid                    ## TO_START
     81  gEfiIp4ProtocolGuid                                  ## TO_START
     82  gEfiIp6ServiceBindingProtocolGuid                    ## TO_START
     83  gEfiIp6ProtocolGuid                                  ## TO_START
     84  gEfiIp6ConfigProtocolGuid                            ## TO_START
     85  gEfiUdp4ServiceBindingProtocolGuid                   ## TO_START
     86  gEfiUdp4ProtocolGuid                                 ## TO_START
     87  gEfiMtftp4ServiceBindingProtocolGuid                 ## TO_START
     88  gEfiMtftp4ProtocolGuid                               ## TO_START
     89  gEfiDhcp4ServiceBindingProtocolGuid                  ## TO_START
     90  gEfiDhcp4ProtocolGuid                                ## TO_START
     91  gEfiUdp6ServiceBindingProtocolGuid                   ## TO_START
     92  gEfiUdp6ProtocolGuid                                 ## TO_START
     93  gEfiMtftp6ServiceBindingProtocolGuid                 ## TO_START
     94  gEfiMtftp6ProtocolGuid                               ## TO_START
     95  gEfiDhcp6ServiceBindingProtocolGuid                  ## TO_START
     96  gEfiDhcp6ProtocolGuid                                ## TO_START
     97  gEfiPxeBaseCodeCallbackProtocolGuid                  ## SOMETIMES_PRODUCES
     98  gEfiPxeBaseCodeProtocolGuid                          ## BY_START
     99  gEfiLoadFileProtocolGuid                             ## BY_START
    96100
    97101[Pcd]
    98   gEfiMdeModulePkgTokenSpaceGuid.PcdTftpBlockSize     ## CONSUMES
     102  gEfiMdeModulePkgTokenSpaceGuid.PcdTftpBlockSize     ## SOMETIMES_CONSUMES
     103[UserExtensions.TianoCore."ExtraFiles"]
     104  UefiPxeBcDxeExtra.uni
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette