Revision: 18743
          http://sourceforge.net/p/edk2/code/18743
Author:   luobozhang
Date:     2015-11-09 03:30:42 +0000 (Mon, 09 Nov 2015)
Log Message:
-----------
NetworkPkg:Enable Http Boot over Ipv6 stack

Add new features to support Http boot over ipv6 stack.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <[email protected]>
Reviewed-by: Fu Siyuan <[email protected]>
Reviewed-by: Ye Ting <[email protected]>
Reviewed-by: Wu Jiaxin <[email protected]>

Modified Paths:
--------------
    trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootClient.c
    trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootComponentName.c
    trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDhcp4.c
    trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDhcp4.h
    trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDxe.c
    trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDxe.h
    trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDxe.inf
    trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDxe.uni
    trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootImpl.c
    trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootImpl.h
    trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootSupport.c
    trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootSupport.h
    trunk/edk2/NetworkPkg/HttpDxe/HttpDns.c
    trunk/edk2/NetworkPkg/HttpDxe/HttpDns.h
    trunk/edk2/NetworkPkg/HttpDxe/HttpDriver.c
    trunk/edk2/NetworkPkg/HttpDxe/HttpDriver.h
    trunk/edk2/NetworkPkg/HttpDxe/HttpDxe.inf
    trunk/edk2/NetworkPkg/HttpDxe/HttpDxe.uni
    trunk/edk2/NetworkPkg/HttpDxe/HttpImpl.c
    trunk/edk2/NetworkPkg/HttpDxe/HttpProto.c
    trunk/edk2/NetworkPkg/HttpDxe/HttpProto.h

Added Paths:
-----------
    trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c
    trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDhcp6.h

Modified: trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootClient.c
===================================================================
--- trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootClient.c  2015-11-09 02:29:31 UTC 
(rev 18742)
+++ trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootClient.c  2015-11-09 03:30:42 UTC 
(rev 18743)
@@ -54,15 +54,28 @@
     Node->Ipv4.StaticIpAddress = FALSE;
     CopyMem (&Node->Ipv4.GatewayIpAddress, &Private->GatewayIp, sizeof 
(EFI_IPv4_ADDRESS));
     CopyMem (&Node->Ipv4.SubnetMask, &Private->SubnetMask, sizeof 
(EFI_IPv4_ADDRESS));
-    
-    TmpDevicePath = AppendDevicePathNode (Private->ParentDevicePath, 
(EFI_DEVICE_PATH_PROTOCOL*) Node);
-    FreePool (Node);
-    if (TmpDevicePath == NULL) {
+  } else {
+    Node = AllocateZeroPool (sizeof (IPv6_DEVICE_PATH));
+    if (Node == NULL) {
       return EFI_OUT_OF_RESOURCES;
     }
-  } else {
-    ASSERT (FALSE);
+    Node->Ipv6.Header.Type     = MESSAGING_DEVICE_PATH;
+    Node->Ipv6.Header.SubType  = MSG_IPv6_DP;
+    SetDevicePathNodeLength (Node, sizeof (IPv6_DEVICE_PATH));
+    Node->Ipv6.PrefixLength    = IP6_PREFIX_LENGTH;
+    Node->Ipv6.RemotePort      = Private->Port;
+    Node->Ipv6.Protocol        = EFI_IP_PROTO_TCP; 
+    Node->Ipv6.IpAddressOrigin = 0;
+    CopyMem (&Node->Ipv6.LocalIpAddress, &Private->StationIp.v6, sizeof 
(EFI_IPv6_ADDRESS));
+    CopyMem (&Node->Ipv6.RemoteIpAddress, &Private->ServerIp.v6, sizeof 
(EFI_IPv6_ADDRESS));
+    CopyMem (&Node->Ipv6.GatewayIpAddress, &Private->GatewayIp.v6, sizeof 
(EFI_IPv6_ADDRESS));
   }
+  
+  TmpDevicePath = AppendDevicePathNode (Private->ParentDevicePath, 
(EFI_DEVICE_PATH_PROTOCOL*) Node);
+  FreePool (Node);
+  if (TmpDevicePath == NULL) {
+    return EFI_OUT_OF_RESOURCES;
+  }
 
   //
   // Update the URI node with the boot file URI.
@@ -85,21 +98,39 @@
     return EFI_OUT_OF_RESOURCES;
   }
 
-  //
-  // Reinstall the device path protocol of the child handle.
-  //
-  Status = gBS->ReinstallProtocolInterface (
-                  Private->ChildHandle,
-                  &gEfiDevicePathProtocolGuid,
-                  Private->DevicePath,
-                  NewDevicePath
-                  );
-  if (EFI_ERROR (Status)) {
-    return Status;
+  if (!Private->UsingIpv6) {
+    //
+    // Reinstall the device path protocol of the child handle.
+    //
+    Status = gBS->ReinstallProtocolInterface (
+                    Private->Ip4Nic->Controller,
+                    &gEfiDevicePathProtocolGuid,
+                    Private->Ip4Nic->DevicePath,
+                    NewDevicePath
+                    );
+    if (EFI_ERROR (Status)) {
+      return Status;
+    }
+    
+    FreePool (Private->Ip4Nic->DevicePath);
+    Private->Ip4Nic->DevicePath = NewDevicePath;
+  } else {
+    //
+    // Reinstall the device path protocol of the child handle.
+    //
+    Status = gBS->ReinstallProtocolInterface (
+                    Private->Ip6Nic->Controller,
+                    &gEfiDevicePathProtocolGuid,
+                    Private->Ip6Nic->DevicePath,
+                    NewDevicePath
+                    );
+    if (EFI_ERROR (Status)) {
+      return Status;
+    }
+    FreePool (Private->Ip6Nic->DevicePath);
+    Private->Ip6Nic->DevicePath = NewDevicePath;
   }
   
-  FreePool (Private->DevicePath);
-  Private->DevicePath = NewDevicePath;
   return EFI_SUCCESS;
 }
 
@@ -113,7 +144,7 @@
 
 **/
 EFI_STATUS
-HttpBootExtractUriInfo (
+HttpBootDhcp4ExtractUriInfo (
   IN     HTTP_BOOT_PRIVATE_DATA   *Private
   )
 {
@@ -193,6 +224,159 @@
 }
 
 /**
+  Parse the boot file URI information from the selected Dhcp6 offer packet.
+
+  @param[in]    Private        The pointer to the driver's private data.
+
+  @retval EFI_SUCCESS          Successfully parsed out all the boot 
information.
+  @retval Others               Failed to parse out the boot information.
+
+**/
+EFI_STATUS
+HttpBootDhcp6ExtractUriInfo (
+  IN     HTTP_BOOT_PRIVATE_DATA   *Private
+  )
+{
+  HTTP_BOOT_DHCP6_PACKET_CACHE    *SelectOffer;
+  HTTP_BOOT_DHCP6_PACKET_CACHE    *HttpOffer;
+  UINT32                          SelectIndex;
+  UINT32                          ProxyIndex;
+  EFI_DHCP6_PACKET_OPTION         *Option;
+  EFI_IPv6_ADDRESS                IpAddr;
+  CHAR8                           *HostName;
+  CHAR16                          *HostNameStr;
+  EFI_STATUS                      Status;
+
+  ASSERT (Private != NULL);
+  ASSERT (Private->SelectIndex != 0);
+  SelectIndex = Private->SelectIndex - 1;
+  ASSERT (SelectIndex < HTTP_BOOT_OFFER_MAX_NUM);
+
+  Status   = EFI_SUCCESS;
+  HostName = NULL;
+  //
+  // SelectOffer contains the IP address configuration and name server 
configuration.
+  // HttpOffer contains the boot file URL.
+  //
+  SelectOffer = &Private->OfferBuffer[SelectIndex].Dhcp6;
+  if ((SelectOffer->OfferType == HttpOfferTypeDhcpIpUri) || 
(SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns)) {
+    HttpOffer = SelectOffer;
+  } else {
+    ASSERT (Private->SelectProxyType != HttpOfferTypeMax);
+    ProxyIndex = Private->OfferIndex[Private->SelectProxyType][0];
+    HttpOffer = &Private->OfferBuffer[ProxyIndex].Dhcp6;
+  }
+
+  //
+  //  Set the Local station address to IP layer.
+  //
+  Status = HttpBootSetIp6Address (Private);
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+  
+  //
+  // Configure the default DNS server if server assigned.
+  //
+  if ((SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns) || 
(SelectOffer->OfferType == HttpOfferTypeDhcpDns)) {
+    Option = SelectOffer->OptList[HTTP_BOOT_DHCP6_IDX_DNS_SERVER];
+    ASSERT (Option != NULL);
+    Status = HttpBootSetIp6Dns (
+               Private,
+               HTONS (Option->OpLen),
+               Option->Data
+               );
+    if (EFI_ERROR (Status)) {
+      return Status;
+    }
+  }
+  
+  //
+  // Extract the HTTP server Ip frome URL. This is used to Check route table 
+  // whether can send message to HTTP Server Ip through the GateWay.
+  //
+  Status = HttpUrlGetIp6 (
+             (CHAR8*) 
HttpOffer->OptList[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data,
+             HttpOffer->UriParser,
+             &IpAddr
+             );
+  
+  if (EFI_ERROR (Status)) {
+    //
+    // The Http server address is expressed by Name Ip, so perform DNS 
resolution
+    //
+    Status = HttpUrlGetHostName (
+               (CHAR8*) 
HttpOffer->OptList[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data,
+               HttpOffer->UriParser,
+               &HostName
+               );
+    if (EFI_ERROR (Status)) {
+      return Status;
+    }
+    
+    HostNameStr = AllocateZeroPool ((AsciiStrLen (HostName) + 1) * sizeof 
(CHAR16));
+    if (HostNameStr == NULL) {
+      Status = EFI_OUT_OF_RESOURCES;
+      goto Error;
+    }
+    
+    AsciiStrToUnicodeStr (HostName, HostNameStr);
+    Status = HttpBootDns (Private, HostNameStr, &IpAddr);
+    FreePool (HostNameStr);
+    if (EFI_ERROR (Status)) {
+      goto Error;
+    }  
+  } 
+  
+  CopyMem (&Private->ServerIp.v6, &IpAddr, sizeof (EFI_IPv6_ADDRESS));  
+    
+  //
+  // register the IPv6 gateway address to the network device.
+  //
+  Status = HttpBootSetIp6Gateway (Private);
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+  
+  //
+  // Extract the port from URL, and use default HTTP port 80 if not provided.
+  //
+  Status = HttpUrlGetPort (
+             (CHAR8*) 
HttpOffer->OptList[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data,
+             HttpOffer->UriParser,
+             &Private->Port
+             );
+  if (EFI_ERROR (Status) || Private->Port == 0) {
+    Private->Port = 80;
+  }
+  
+  //
+  // Record the URI of boot file from the selected HTTP offer.
+  //
+  Private->BootFileUriParser = HttpOffer->UriParser;
+  Private->BootFileUri = (CHAR8*) 
HttpOffer->OptList[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data;
+
+  
+  //
+  // All boot informations are valid here.
+  //
+  AsciiPrint ("\n  URI: %a", Private->BootFileUri);
+  //
+  // Update the device path to include the IP and boot URI information.
+  //
+  Status = HttpBootUpdateDevicePath (Private);
+
+Error:
+  
+  if (HostName != NULL) {
+    FreePool (HostName);
+  }
+    
+  return Status;
+}
+
+
+/**
   Discover all the boot information for boot file.
 
   @param[in, out]    Private        The pointer to the driver's private data.
@@ -218,9 +402,9 @@
   }
 
   if (!Private->UsingIpv6) {
-    Status = HttpBootExtractUriInfo (Private);
+    Status = HttpBootDhcp4ExtractUriInfo (Private);
   } else {
-    ASSERT (FALSE);
+    Status = HttpBootDhcp6ExtractUriInfo (Private);
   }
 
   return Status;
@@ -247,12 +431,14 @@
 
   ZeroMem (&ConfigData, sizeof (HTTP_IO_CONFIG_DATA));
   if (!Private->UsingIpv6) {
-    ConfigData.Config4.HttpVersion = HttpVersion11;
+    ConfigData.Config4.HttpVersion    = HttpVersion11;
     ConfigData.Config4.RequestTimeOut = HTTP_BOOT_REQUEST_TIMEOUT;
     IP4_COPY_ADDRESS (&ConfigData.Config4.LocalIp, &Private->StationIp.v4);
     IP4_COPY_ADDRESS (&ConfigData.Config4.SubnetMask, &Private->SubnetMask.v4);
   } else {
-    ASSERT (FALSE);
+    ConfigData.Config6.HttpVersion    = HttpVersion11;
+    ConfigData.Config6.RequestTimeOut = HTTP_BOOT_REQUEST_TIMEOUT;
+    IP6_COPY_ADDRESS (&ConfigData.Config6.LocalIp, &Private->StationIp.v6);
   }
 
   Status = HttpIoCreateIo (

Modified: trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootComponentName.c
===================================================================
--- trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootComponentName.c   2015-11-09 
02:29:31 UTC (rev 18742)
+++ trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootComponentName.c   2015-11-09 
03:30:42 UTC (rev 18743)
@@ -151,7 +151,10 @@
   
   NicHandle = HttpBootGetNicByIp4Children (ControllerHandle);
   if (NicHandle == NULL) {
-    return EFI_UNSUPPORTED;
+    NicHandle = HttpBootGetNicByIp6Children(ControllerHandle);
+    if (NicHandle == NULL) {
+      return EFI_UNSUPPORTED;
+    }
   }
 
   //

Modified: trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDhcp4.c
===================================================================
--- trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDhcp4.c   2015-11-09 02:29:31 UTC 
(rev 18742)
+++ trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDhcp4.c   2015-11-09 03:30:42 UTC 
(rev 18743)
@@ -319,7 +319,7 @@
   }
 
   //
-  // The offer with "HttpClient" is a Http offer.
+  // The offer with "HTTPClient" is a Http offer.
   //
   Option = Options[HTTP_BOOT_DHCP4_TAG_INDEX_CLASS_ID];
   if ((Option != NULL) && (Option->Length >= 9) &&
@@ -461,13 +461,13 @@
 }
 
 /**
-  Select an DHCPv4 offer, and record SelectIndex and SelectProxyType.
+  Select an DHCPv4 or DHCP6 offer, and record SelectIndex and SelectProxyType.
 
   @param[in]  Private             Pointer to HTTP boot driver private data.
 
 **/
 VOID
-HttpBootSelectDhcp4Offer (
+HttpBootSelectDhcpOffer (
   IN HTTP_BOOT_PRIVATE_DATA  *Private
   )
 {
@@ -590,7 +590,7 @@
     // Select offer according to the priority in UEFI spec, and record the 
SelectIndex 
     // and SelectProxyType.
     //
-    HttpBootSelectDhcp4Offer (Private);
+    HttpBootSelectDhcpOffer (Private);
 
     if (Private->SelectIndex == 0) {
       Status = EFI_ABORTED;
@@ -689,7 +689,7 @@
 
 **/
 EFI_STATUS
-HttpBootSetIpPolicy (
+HttpBootSetIp4Policy (
   IN HTTP_BOOT_PRIVATE_DATA         *Private
   )
 {
@@ -752,7 +752,7 @@
   Dhcp4 = Private->Dhcp4;
   ASSERT (Dhcp4 != NULL);
 
-  Status = HttpBootSetIpPolicy (Private);
+  Status = HttpBootSetIp4Policy (Private);
   if (EFI_ERROR (Status)) {
     return Status;
   }

Modified: trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDhcp4.h
===================================================================
--- trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDhcp4.h   2015-11-09 02:29:31 UTC 
(rev 18742)
+++ trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDhcp4.h   2015-11-09 03:30:42 UTC 
(rev 18743)
@@ -246,6 +246,17 @@
 } HTTP_BOOT_DHCP4_PACKET_CACHE;
 
 /**
+  Select an DHCPv4 or DHCP6 offer, and record SelectIndex and SelectProxyType.
+
+  @param[in]  Private             Pointer to HTTP boot driver private data.
+
+**/
+VOID
+HttpBootSelectDhcpOffer (
+  IN HTTP_BOOT_PRIVATE_DATA  *Private
+  );
+
+/**
   Start the D.O.R.A DHCPv4 process to acquire the IPv4 address and other Http 
boot information.
 
   @param[in]  Private           Pointer to HTTP_BOOT private data.

Added: trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c
===================================================================
--- trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c                           
(rev 0)
+++ trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c   2015-11-09 03:30:42 UTC 
(rev 18743)
@@ -0,0 +1,984 @@
+/** @file
+  Functions implementation related with DHCPv6 for HTTP boot driver.
+
+Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available 
under 
+the terms and conditions of the BSD License that accompanies this 
distribution.  
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.                                
          
+    
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,          
           
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include "HttpBootDxe.h"
+
+/**
+  Build the options buffer for the DHCPv6 request packet.
+
+  @param[in]  Private             The pointer to HTTP BOOT driver private data.
+  @param[out] OptList             The pointer to the option pointer array.
+  @param[in]  Buffer              The pointer to the buffer to contain the 
option list.
+
+  @return     Index               The count of the built-in options.
+
+**/
+UINT32
+HttpBootBuildDhcp6Options (
+  IN  HTTP_BOOT_PRIVATE_DATA       *Private,
+  OUT EFI_DHCP6_PACKET_OPTION      **OptList,
+  IN  UINT8                        *Buffer
+  )
+{
+  HTTP_BOOT_DHCP6_OPTION_ENTRY     OptEnt;
+  UINT16                           Value;
+  UINT32                           Index;
+
+  Index      = 0;
+  OptList[0] = (EFI_DHCP6_PACKET_OPTION *) Buffer;
+
+  //
+  // Append client option request option
+  //
+  OptList[Index]->OpCode     = HTONS (HTTP_BOOT_DHCP6_OPT_ORO);
+  OptList[Index]->OpLen      = HTONS (8);
+  OptEnt.Oro                 = (HTTP_BOOT_DHCP6_OPTION_ORO *) 
OptList[Index]->Data;
+  OptEnt.Oro->OpCode[0]      = HTONS(HTTP_BOOT_DHCP6_OPT_BOOT_FILE_URL);
+  OptEnt.Oro->OpCode[1]      = HTONS(HTTP_BOOT_DHCP6_OPT_BOOT_FILE_PARAM);
+  OptEnt.Oro->OpCode[2]      = HTONS(HTTP_BOOT_DHCP6_OPT_DNS_SERVERS);
+  OptEnt.Oro->OpCode[3]      = HTONS(HTTP_BOOT_DHCP6_OPT_VENDOR_CLASS);
+  Index++;
+  OptList[Index]             = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
+
+  //
+  // Append client network device interface option
+  //
+  OptList[Index]->OpCode     = HTONS (HTTP_BOOT_DHCP6_OPT_UNDI);
+  OptList[Index]->OpLen      = HTONS ((UINT16)3);
+  OptEnt.Undi                = (HTTP_BOOT_DHCP6_OPTION_UNDI *) 
OptList[Index]->Data;
+
+  if (Private->Nii != NULL) {
+    OptEnt.Undi->Type        = Private->Nii->Type;
+    OptEnt.Undi->MajorVer    = Private->Nii->MajorVer;
+    OptEnt.Undi->MinorVer    = Private->Nii->MinorVer;
+  } else {
+    OptEnt.Undi->Type        = DEFAULT_UNDI_TYPE;
+    OptEnt.Undi->MajorVer    = DEFAULT_UNDI_MAJOR;
+    OptEnt.Undi->MinorVer    = DEFAULT_UNDI_MINOR;
+  }
+
+  Index++;
+  OptList[Index]             = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
+
+  //
+  // Append client system architecture option
+  //
+  OptList[Index]->OpCode     = HTONS (HTTP_BOOT_DHCP6_OPT_ARCH);
+  OptList[Index]->OpLen      = HTONS ((UINT16) sizeof 
(HTTP_BOOT_DHCP6_OPTION_ARCH));
+  OptEnt.Arch                = (HTTP_BOOT_DHCP6_OPTION_ARCH *) 
OptList[Index]->Data;
+  Value                      = HTONS 
(EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE);
+  CopyMem (&OptEnt.Arch->Type, &Value, sizeof (UINT16));
+  Index++;
+  OptList[Index]             = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
+
+  //
+  // Append vendor class identify option.
+  //
+  OptList[Index]->OpCode       = HTONS (HTTP_BOOT_DHCP6_OPT_VENDOR_CLASS);
+  OptList[Index]->OpLen        = HTONS ((UINT16) sizeof 
(HTTP_BOOT_DHCP6_OPTION_VENDOR_CLASS));
+  OptEnt.VendorClass           = (HTTP_BOOT_DHCP6_OPTION_VENDOR_CLASS *) 
OptList[Index]->Data;
+  OptEnt.VendorClass->Vendor   = HTONL (HTTP_BOOT_DHCP6_ENTERPRISE_NUM);
+  OptEnt.VendorClass->ClassLen = HTONS ((UINT16) sizeof (HTTP_BOOT_CLASS_ID));
+  CopyMem (
+    &OptEnt.VendorClass->ClassId,
+    DEFAULT_CLASS_ID_DATA,
+    sizeof (HTTP_BOOT_CLASS_ID)
+    );
+  HttpBootUintnToAscDecWithFormat (
+    EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE,
+    OptEnt.VendorClass->ClassId.ArchitectureType,
+    sizeof (OptEnt.VendorClass->ClassId.ArchitectureType)
+    );
+
+  if (Private->Nii != NULL) {
+    CopyMem (
+      OptEnt.VendorClass->ClassId.InterfaceName,
+      Private->Nii->StringId,
+      sizeof (OptEnt.VendorClass->ClassId.InterfaceName)
+      );
+    HttpBootUintnToAscDecWithFormat (
+      Private->Nii->MajorVer,
+      OptEnt.VendorClass->ClassId.UndiMajor,
+      sizeof (OptEnt.VendorClass->ClassId.UndiMajor)
+      );
+    HttpBootUintnToAscDecWithFormat (
+      Private->Nii->MinorVer,
+      OptEnt.VendorClass->ClassId.UndiMinor,
+      sizeof (OptEnt.VendorClass->ClassId.UndiMinor)
+      );
+  }
+
+  Index++;
+
+  return Index;
+}
+
+/**
+  Parse out a DHCPv6 option by OptTag, and find the position in buffer.
+
+  @param[in]  Buffer        The pointer to the option buffer.
+  @param[in]  Length        Length of the option buffer.
+  @param[in]  OptTag        The required option tag.
+
+  @retval     NULL          Failed to parse the required option.
+  @retval     Others        The postion of the required option in buffer.
+
+**/
+EFI_DHCP6_PACKET_OPTION *
+HttpBootParseDhcp6Options (
+  IN UINT8                       *Buffer,
+  IN UINT32                      Length,
+  IN UINT16                      OptTag
+  )
+{
+  EFI_DHCP6_PACKET_OPTION        *Option;
+  UINT32                         Offset;
+
+  Option  = (EFI_DHCP6_PACKET_OPTION *) Buffer;
+  Offset  = 0;
+
+  //
+  // OpLen and OpCode here are both stored in network order.
+  //
+  while (Offset < Length) {
+
+    if (NTOHS (Option->OpCode) == OptTag) {
+
+      return Option;
+    }
+
+    Offset += (NTOHS(Option->OpLen) + 4);
+    Option  = (EFI_DHCP6_PACKET_OPTION *) (Buffer + Offset);
+  }
+
+  return NULL;
+
+}
+
+/**
+  Parse the cached DHCPv6 packet, including all the options.
+
+  @param[in]  Cache6           The pointer to a cached DHCPv6 packet.
+
+  @retval     EFI_SUCCESS      Parsed the DHCPv6 packet successfully.
+  @retval     EFI_DEVICE_ERROR Failed to parse and invalid the packet.
+
+**/
+EFI_STATUS
+HttpBootParseDhcp6Packet (
+  IN  HTTP_BOOT_DHCP6_PACKET_CACHE    *Cache6
+  )
+{
+  EFI_DHCP6_PACKET               *Offer;
+  EFI_DHCP6_PACKET_OPTION        **Options;
+  EFI_DHCP6_PACKET_OPTION        *Option;
+  HTTP_BOOT_OFFER_TYPE           OfferType;
+  EFI_IPv6_ADDRESS               IpAddr;
+  BOOLEAN                        IsProxyOffer;
+  BOOLEAN                        IsHttpOffer;
+  BOOLEAN                        IsDnsOffer;
+  BOOLEAN                        IpExpressedUri;
+  EFI_STATUS                     Status;
+  UINT32                         Offset;
+  UINT32                         Length;
+  
+  IsDnsOffer     = FALSE;
+  IpExpressedUri = FALSE;
+  IsProxyOffer   = TRUE;
+  IsHttpOffer    = FALSE;
+  Offer        = &Cache6->Packet.Offer;
+  Options      = Cache6->OptList;
+  
+  ZeroMem (Cache6->OptList, sizeof (Cache6->OptList));
+
+  Option  = (EFI_DHCP6_PACKET_OPTION *) (Offer->Dhcp6.Option);
+  Offset  = 0;
+  Length  = GET_DHCP6_OPTION_SIZE (Offer);
+
+  //
+  // OpLen and OpCode here are both stored in network order, since they are 
from original packet.
+  //
+  while (Offset < Length) {
+
+    if (NTOHS (Option->OpCode) == HTTP_BOOT_DHCP6_OPT_IA_NA) {
+      Options[HTTP_BOOT_DHCP6_IDX_IA_NA] = Option;
+    } else if (NTOHS (Option->OpCode) == HTTP_BOOT_DHCP6_OPT_BOOT_FILE_URL) {
+      //
+      // The server sends this option to inform the client about an URL to a 
boot file.
+      //
+      Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL] = Option;
+    } else if (NTOHS (Option->OpCode) == HTTP_BOOT_DHCP6_OPT_BOOT_FILE_PARAM) {
+      Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_PARAM] = Option;
+    } else if (NTOHS (Option->OpCode) == HTTP_BOOT_DHCP6_OPT_VENDOR_CLASS) {
+      Options[HTTP_BOOT_DHCP6_IDX_VENDOR_CLASS] = Option;
+    } else if (NTOHS (Option->OpCode) == HTTP_BOOT_DHCP6_OPT_DNS_SERVERS) {
+      Options[HTTP_BOOT_DHCP6_IDX_DNS_SERVER] = Option;
+    }
+
+    Offset += (NTOHS (Option->OpLen) + 4);
+    Option  = (EFI_DHCP6_PACKET_OPTION *) (Offer->Dhcp6.Option + Offset);
+  }
+  //
+  // The offer with assigned client address is NOT a proxy offer.
+  // An ia_na option, embeded with valid ia_addr option and a status_code of 
success.
+  //
+  Option = Options[HTTP_BOOT_DHCP6_IDX_IA_NA];
+  if (Option != NULL) {
+    Option = HttpBootParseDhcp6Options (
+               Option->Data + 12,
+               NTOHS (Option->OpLen),
+               HTTP_BOOT_DHCP6_OPT_STATUS_CODE
+               );
+    if ((Option != NULL && Option->Data[0] == 0) || (Option == NULL)) {
+      IsProxyOffer = FALSE;
+    }
+  }
+
+  //
+  // The offer with "HTTPClient" is a Http offer.
+  //
+  Option = Options[HTTP_BOOT_DHCP6_IDX_VENDOR_CLASS];
+
+  if (Option != NULL &&
+      NTOHS(Option->OpLen) >= 10 &&
+      CompareMem (Option->Data, DEFAULT_CLASS_ID_DATA, 10) == 0) {
+      IsHttpOffer = TRUE;
+  }
+
+  //
+  // The offer with Domain Server is a DNS offer.
+  //
+  Option = Options[HTTP_BOOT_DHCP6_IDX_DNS_SERVER];
+  if (Option != NULL) {
+    IsDnsOffer = TRUE;
+  }
+
+  //
+  // Http offer must have a boot URI.
+  //
+  if (IsHttpOffer && Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL] == NULL) {
+    return EFI_DEVICE_ERROR;
+  }
+ 
+  //
+  // Try to retrieve the IP of HTTP server from URI. 
+  //
+  if (IsHttpOffer) {
+    Status = HttpParseUrl (
+               (CHAR8*) Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data,
+               (UINT32) AsciiStrLen ((CHAR8*) 
Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data),
+               FALSE,
+               &Cache6->UriParser
+               );
+    if (EFI_ERROR (Status)) {
+      return EFI_DEVICE_ERROR;
+    }
+
+    Status = HttpUrlGetIp6 (
+               (CHAR8*) Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data,
+               Cache6->UriParser,
+               &IpAddr
+               );
+    IpExpressedUri = !EFI_ERROR (Status);
+  }
+
+  //
+  // Determine offer type of the DHCPv6 packet.
+  //
+  if (IsHttpOffer) {
+    if (IpExpressedUri) {
+      OfferType = IsProxyOffer ? HttpOfferTypeProxyIpUri : 
HttpOfferTypeDhcpIpUri;
+    } else {
+      if (!IsProxyOffer) {
+        OfferType = IsDnsOffer ? HttpOfferTypeDhcpNameUriDns : 
HttpOfferTypeDhcpNameUri;
+      } else {
+        OfferType = HttpOfferTypeProxyNameUri;
+      }
+    }
+
+  } else {
+    if (!IsProxyOffer) {
+      OfferType = IsDnsOffer ? HttpOfferTypeDhcpDns : HttpOfferTypeDhcpOnly;
+    } else {
+      return EFI_DEVICE_ERROR;
+    }
+  }
+  
+  Cache6->OfferType = OfferType;
+  return EFI_SUCCESS;
+}
+
+/**
+  Cache the DHCPv6 packet.
+
+  @param[in]  Dst          The pointer to the cache buffer for DHCPv6 packet.
+  @param[in]  Src          The pointer to the DHCPv6 packet to be cached.
+
+**/
+VOID
+HttpBootCacheDhcp6Packet (
+  IN EFI_DHCP6_PACKET          *Dst,
+  IN EFI_DHCP6_PACKET          *Src
+  )
+{
+  ASSERT (Dst->Size >= Src->Length);
+
+  CopyMem (&Dst->Dhcp6, &Src->Dhcp6, Src->Length);
+  Dst->Length = Src->Length;
+}
+
+/**
+  Cache all the received DHCPv6 offers, and set OfferIndex and OfferCount.
+
+  @param[in]  Private               The pointer to HTTP_BOOT_PRIVATE_DATA.
+  @param[in]  RcvdOffer             The pointer to the received offer packet.
+
+**/
+VOID
+HttpBootCacheDhcp6Offer (
+  IN HTTP_BOOT_PRIVATE_DATA  *Private,
+  IN EFI_DHCP6_PACKET        *RcvdOffer
+  )
+{
+  HTTP_BOOT_DHCP6_PACKET_CACHE   *Cache6;
+  EFI_DHCP6_PACKET               *Offer;
+  HTTP_BOOT_OFFER_TYPE           OfferType;
+
+  Cache6 = &Private->OfferBuffer[Private->OfferNum].Dhcp6;
+  Offer  = &Cache6->Packet.Offer;
+
+  //
+  // Cache the content of DHCPv6 packet firstly.
+  //
+  HttpBootCacheDhcp6Packet(Offer, RcvdOffer);
+
+  //
+  // Validate the DHCPv6 packet, and parse the options and offer type.
+  //
+  if (EFI_ERROR (HttpBootParseDhcp6Packet (Cache6))) {
+    return ;
+  }
+
+  //
+  // Determine whether cache the current offer by type, and record OfferIndex 
and OfferCount.
+  //
+  OfferType = Cache6->OfferType;
+  ASSERT (OfferType < HttpOfferTypeMax);
+  ASSERT (Private->OfferCount[OfferType] < HTTP_BOOT_OFFER_MAX_NUM);
+  Private->OfferIndex[OfferType][Private->OfferCount[OfferType]] = 
Private->OfferNum;
+  Private->OfferCount[OfferType]++;
+  Private->OfferNum++;  
+}
+
+/**
+  EFI_DHCP6_CALLBACK is provided by the consumer of the EFI DHCPv6 Protocol 
driver
+  to intercept events that occurred in the configuration process.
+
+  @param[in]  This              The pointer to the EFI DHCPv6 Protocol.
+  @param[in]  Context           The pointer to the context set by 
EFI_DHCP6_PROTOCOL.Configure().
+  @param[in]  CurrentState      The current operational state of the EFI DHCPv 
Protocol driver.
+  @param[in]  Dhcp6Event        The event that occurs in the current state, 
which usually means a
+                                state transition.
+  @param[in]  Packet            The DHCPv6 packet that is going to be sent or 
was already received.
+  @param[out] NewPacket         The packet that is used to replace the Packet 
above.
+
+  @retval EFI_SUCCESS           Told the EFI DHCPv6 Protocol driver to 
continue the DHCP process.
+  @retval EFI_NOT_READY         Only used in the Dhcp6Selecting state. The EFI 
DHCPv6 Protocol
+                                driver will continue to wait for more packets.
+  @retval EFI_ABORTED           Told the EFI DHCPv6 Protocol driver to abort 
the current process.
+
+**/
+EFI_STATUS
+EFIAPI
+HttpBootDhcp6CallBack (
+  IN  EFI_DHCP6_PROTOCOL           *This,
+  IN  VOID                         *Context,
+  IN  EFI_DHCP6_STATE              CurrentState,
+  IN  EFI_DHCP6_EVENT              Dhcp6Event,
+  IN  EFI_DHCP6_PACKET             *Packet,
+  OUT EFI_DHCP6_PACKET             **NewPacket     OPTIONAL
+  )
+{
+   HTTP_BOOT_PRIVATE_DATA          *Private;
+   EFI_DHCP6_PACKET                *SelectAd;
+   EFI_STATUS                      Status;
+   if ((Dhcp6Event != Dhcp6RcvdAdvertise) && (Dhcp6Event != 
Dhcp6SelectAdvertise)) {
+     return EFI_SUCCESS;
+   }
+
+   ASSERT (Packet != NULL);
+   
+   Private     = (HTTP_BOOT_PRIVATE_DATA *) Context;
+   Status = EFI_SUCCESS;
+   switch (Dhcp6Event) {
+    
+   case Dhcp6RcvdAdvertise:
+     Status = EFI_NOT_READY;
+     if (Private->OfferNum < HTTP_BOOT_OFFER_MAX_NUM) {
+       //
+       // Cache the dhcp offers to OfferBuffer[] for select later, and record
+       // the OfferIndex and OfferCount.
+       //
+       HttpBootCacheDhcp6Offer (Private, Packet);
+     }
+     break;
+
+   case Dhcp6SelectAdvertise:
+     //
+     // Select offer by the default policy or by order, and record the 
SelectIndex
+     // and SelectProxyType.
+     //
+     HttpBootSelectDhcpOffer (Private);
+
+     if (Private->SelectIndex == 0) {
+       Status = EFI_ABORTED;
+     } else {
+       ASSERT (NewPacket != NULL);
+       SelectAd   = &Private->OfferBuffer[Private->SelectIndex - 
1].Dhcp6.Packet.Offer;
+       *NewPacket = AllocateZeroPool (SelectAd->Size);
+       ASSERT (*NewPacket != NULL);
+       CopyMem (*NewPacket, SelectAd, SelectAd->Size);
+     }
+     break;
+     
+   default:
+     break;
+  }
+
+  return Status;   
+}
+
+/**
+  Check whether IP driver could route the message which will be sent to 
ServerIp address.
+  
+  This function will check the IP6 route table every 1 seconds until specified 
timeout is expired, if a valid
+  route is found in IP6 route table, the address will be filed in GatewayAddr 
and return.
+
+  @param[in]  Private             The pointer to HTTP_BOOT_PRIVATE_DATA.
+  @param[in]  TimeOutInSecond     Timeout value in seconds.
+  @param[out] GatewayAddr         Pointer to store the gateway IP address.
+
+  @retval     EFI_SUCCESS         Found a valid gateway address successfully.
+  @retval     EFI_TIMEOUT         The operation is time out.
+  @retval     Other               Unexpect error happened.
+  
+**/
+EFI_STATUS
+HttpBootCheckRouteTable (
+  IN  HTTP_BOOT_PRIVATE_DATA        *Private,
+  IN  UINTN                         TimeOutInSecond,
+  OUT EFI_IPv6_ADDRESS              *GatewayAddr
+  )
+{
+  EFI_STATUS                       Status;
+  EFI_IP6_PROTOCOL                 *Ip6;
+  EFI_IP6_MODE_DATA                Ip6ModeData;
+  UINTN                            Index;
+  EFI_EVENT                        TimeOutEvt;
+  UINTN                            RetryCount;
+  BOOLEAN                          GatewayIsFound;
+
+  ASSERT (GatewayAddr != NULL);
+  ASSERT (Private != NULL);
+
+  Ip6            = Private->Ip6;
+  GatewayIsFound = FALSE;
+  RetryCount     = 0;
+  TimeOutEvt     = NULL;
+  Status         = EFI_SUCCESS;
+  ZeroMem (GatewayAddr, sizeof (EFI_IPv6_ADDRESS));
+
+  while (TRUE) {
+    Status = Ip6->GetModeData (Ip6, &Ip6ModeData, NULL, NULL);
+    if (EFI_ERROR (Status)) {
+      goto ON_EXIT;
+    }
+    
+    //
+    // Find out the gateway address which can route the message which send to 
ServerIp.
+    //
+    for (Index = 0; Index < Ip6ModeData.RouteCount; Index++) {
+      if (NetIp6IsNetEqual (&Private->ServerIp.v6, 
&Ip6ModeData.RouteTable[Index].Destination, 
Ip6ModeData.RouteTable[Index].PrefixLength)) {
+        IP6_COPY_ADDRESS (GatewayAddr, &Ip6ModeData.RouteTable[Index].Gateway);
+        GatewayIsFound = TRUE;
+        break;
+      }
+    }
+
+    if (Ip6ModeData.AddressList != NULL) {
+      FreePool (Ip6ModeData.AddressList);
+    }
+    if (Ip6ModeData.GroupTable != NULL) {
+      FreePool (Ip6ModeData.GroupTable);
+    }
+    if (Ip6ModeData.RouteTable != NULL) {
+      FreePool (Ip6ModeData.RouteTable);
+    }
+    if (Ip6ModeData.NeighborCache != NULL) {
+      FreePool (Ip6ModeData.NeighborCache);
+    }
+    if (Ip6ModeData.PrefixTable != NULL) {
+      FreePool (Ip6ModeData.PrefixTable);
+    }
+    if (Ip6ModeData.IcmpTypeList != NULL) {
+      FreePool (Ip6ModeData.IcmpTypeList);
+    }
+    
+    if (GatewayIsFound || RetryCount == TimeOutInSecond) {
+      break;
+    }
+    
+    RetryCount++;
+    
+    //
+    // Delay 1 second then recheck it again.
+    //
+    if (TimeOutEvt == NULL) {
+      Status = gBS->CreateEvent (
+                      EVT_TIMER,
+                      TPL_CALLBACK,
+                      NULL,
+                      NULL,
+                      &TimeOutEvt
+                      );
+      if (EFI_ERROR (Status)) {
+        goto ON_EXIT;
+      }
+    }
+
+    Status = gBS->SetTimer (TimeOutEvt, TimerRelative, TICKS_PER_SECOND);
+    if (EFI_ERROR (Status)) {
+      goto ON_EXIT;
+    }
+    while (EFI_ERROR (gBS->CheckEvent (TimeOutEvt))) {
+      Ip6->Poll (Ip6);
+    }
+  }
+  
+ON_EXIT:
+  if (TimeOutEvt != NULL) {
+    gBS->CloseEvent (TimeOutEvt);
+  }
+  
+  if (GatewayIsFound) {
+    Status = EFI_SUCCESS;
+  } else if (RetryCount == TimeOutInSecond) {
+    Status = EFI_TIMEOUT;
+  }
+
+  return Status; 
+}
+
+/**
+  Set the IP6 policy to Automatic.
+
+  @param[in]  Private             The pointer to HTTP_BOOT_PRIVATE_DATA.
+
+  @retval     EFI_SUCCESS         Switch the IP policy succesfully.
+  @retval     Others              Unexpect error happened.
+
+**/
+EFI_STATUS
+HttpBootSetIp6Policy (
+  IN HTTP_BOOT_PRIVATE_DATA        *Private
+  )
+{
+  EFI_IP6_CONFIG_POLICY            Policy;
+  EFI_IP6_CONFIG_PROTOCOL          *Ip6Config;
+  EFI_STATUS                       Status;
+  UINTN                            DataSize;
+
+  Ip6Config       = Private->Ip6Config;
+  DataSize        = sizeof (EFI_IP6_CONFIG_POLICY);
+  
+  //
+  // Get and store the current policy of IP6 driver.
+  //
+  Status = Ip6Config->GetData (
+                        Ip6Config,
+                        Ip6ConfigDataTypePolicy,
+                        &DataSize,
+                        &Policy
+                        );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  if (Policy == Ip6ConfigPolicyManual) {
+    Policy = Ip6ConfigPolicyAutomatic;
+    Status = Ip6Config->SetData (
+                          Ip6Config,
+                          Ip6ConfigDataTypePolicy,
+                          sizeof(EFI_IP6_CONFIG_POLICY),
+                          &Policy
+                          );
+    if (EFI_ERROR (Status)) {
+      return Status;
+    }
+  }
+  return EFI_SUCCESS;
+}
+
+/**
+  This function will register the default DNS addresses to the network device.
+  
+  @param[in]  Private             The pointer to HTTP_BOOT_PRIVATE_DATA.
+  @param[in]  DataLength          Size of the buffer pointed to by 
DnsServerData in bytes.
+  @param[in]  DnsServerData       Point a list of DNS server address in an 
array
+                                  of EFI_IPv6_ADDRESS instances.
+
+  @retval     EFI_SUCCESS         The DNS configuration has been configured 
successfully.
+  @retval     Others              Failed to configure the address.
+
+**/
+EFI_STATUS
+HttpBootSetIp6Dns (
+  IN HTTP_BOOT_PRIVATE_DATA         *Private,
+  IN UINTN                          DataLength,
+  IN VOID                           *DnsServerData
+  )
+{
+  EFI_IP6_CONFIG_PROTOCOL        *Ip6Config;
+  
+  ASSERT (Private->UsingIpv6);
+
+  Ip6Config = Private->Ip6Config;
+  
+  return Ip6Config->SetData (
+                      Ip6Config,
+                      Ip6ConfigDataTypeDnsServer,
+                      DataLength,
+                      DnsServerData
+                      );
+}
+
+/**
+  This function will register the IPv6 gateway address to the network device.
+  
+  @param[in]  Private             The pointer to HTTP_BOOT_PRIVATE_DATA.
+
+  @retval     EFI_SUCCESS         The new IP configuration has been configured 
successfully.
+  @retval     Others              Failed to configure the address.
+
+**/
+EFI_STATUS
+HttpBootSetIp6Gateway (
+  IN HTTP_BOOT_PRIVATE_DATA         *Private
+  )
+{
+  EFI_IP6_CONFIG_PROTOCOL           *Ip6Config;
+  EFI_STATUS                        Status;
+
+  ASSERT (Private->UsingIpv6);
+  Ip6Config = Private->Ip6Config;
+ 
+  //
+  // Set the default gateway address. 
+  //
+  if (!Private->NoGateway && !NetIp6IsUnspecifiedAddr 
(&Private->GatewayIp.v6)) {
+    Status = Ip6Config->SetData (
+                          Ip6Config,
+                          Ip6ConfigDataTypeGateway,
+                          sizeof (EFI_IPv6_ADDRESS),
+                          &Private->GatewayIp.v6
+                          );
+    if (EFI_ERROR(Status)) {
+      return Status;
+    }
+  }
+
+  return EFI_SUCCESS;
+}
+
+/**
+  This function will register the station IP address.
+  
+  @param[in]  Private             The pointer to HTTP_BOOT_PRIVATE_DATA.
+
+  @retval     EFI_SUCCESS         The new IP address has been configured 
successfully.
+  @retval     Others              Failed to configure the address.
+
+**/
+EFI_STATUS
+HttpBootSetIp6Address (
+  IN HTTP_BOOT_PRIVATE_DATA         *Private
+)
+{
+  EFI_STATUS                         Status;
+  EFI_IP6_PROTOCOL                   *Ip6;
+  EFI_IP6_CONFIG_PROTOCOL            *Ip6Cfg;
+  EFI_IP6_CONFIG_POLICY              Policy;
+  EFI_IP6_CONFIG_MANUAL_ADDRESS      CfgAddr;
+  EFI_IPv6_ADDRESS                   *Ip6Addr;
+  EFI_IPv6_ADDRESS                   GatewayAddr;
+  EFI_IP6_CONFIG_DATA                Ip6CfgData;
+  EFI_EVENT                          MappedEvt; 
+  UINTN                              DataSize;
+  BOOLEAN                            IsAddressOk;
+  UINTN                              Index;
+
+  ASSERT (Private->UsingIpv6);
+  
+  MappedEvt   = NULL;
+  IsAddressOk = FALSE;
+  Ip6Addr     = NULL;
+  Ip6Cfg      = Private->Ip6Config;
+  Ip6         = Private->Ip6;
+  
+  ZeroMem (&CfgAddr, sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS));
+  CopyMem (&CfgAddr, &Private->StationIp.v6, sizeof (EFI_IPv6_ADDRESS));
+  ZeroMem (&Ip6CfgData, sizeof (EFI_IP6_CONFIG_DATA));
+  
+  Ip6CfgData.AcceptIcmpErrors    = TRUE;
+  Ip6CfgData.DefaultProtocol     = IP6_ICMP;
+  Ip6CfgData.HopLimit            = HTTP_BOOT_DEFAULT_HOPLIMIT;
+  Ip6CfgData.ReceiveTimeout      = HTTP_BOOT_DEFAULT_LIFETIME;
+  Ip6CfgData.TransmitTimeout     = HTTP_BOOT_DEFAULT_LIFETIME;
+    
+  Status = Ip6->Configure (Ip6, &Ip6CfgData);
+  if (EFI_ERROR (Status)) {
+    goto ON_EXIT;
+  }
+
+  //
+  // Retrieve the gateway address from IP6 route table.
+  //
+  Status = HttpBootCheckRouteTable (Private, 
HTTP_BOOT_IP6_ROUTE_TABLE_TIMEOUT, &GatewayAddr);
+  if (EFI_ERROR (Status)) {
+    Private->NoGateway = TRUE;
+  } else {
+    IP6_COPY_ADDRESS (&Private->GatewayIp.v6, &GatewayAddr);
+  }
+
+  //
+  // Set the new address by Ip6ConfigProtocol manually.
+  //
+  Policy = Ip6ConfigPolicyManual;
+  Status = Ip6Cfg->SetData (
+                     Ip6Cfg,
+                     Ip6ConfigDataTypePolicy,
+                     sizeof(EFI_IP6_CONFIG_POLICY),
+                     &Policy
+                     );
+  if (EFI_ERROR (Status)) {
+    goto ON_EXIT;
+  }
+  
+  //
+  // Create a notify event to set address flag when DAD if IP6 driver 
succeeded.
+  //
+  Status = gBS->CreateEvent (
+                  EVT_NOTIFY_SIGNAL,
+                  TPL_NOTIFY,
+                  HttpBootCommonNotify,
+                  &IsAddressOk,
+                  &MappedEvt
+                  );
+  if (EFI_ERROR (Status)) {
+    goto ON_EXIT;
+  }
+  
+  //
+  // Set static host ip6 address. This is a asynchronous process.
+  //
+  Status = Ip6Cfg->RegisterDataNotify (
+                     Ip6Cfg,
+                     Ip6ConfigDataTypeManualAddress,
+                     MappedEvt
+                     );
+  if (EFI_ERROR(Status)) {
+    goto ON_EXIT;
+  }
+
+  Status = Ip6Cfg->SetData (
+                     Ip6Cfg,
+                     Ip6ConfigDataTypeManualAddress,
+                     sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS),
+                     &CfgAddr
+                     ); 
+  if (EFI_ERROR (Status) && Status != EFI_NOT_READY) {
+    goto ON_EXIT;
+  } else if (Status == EFI_NOT_READY) {
+    //
+    // Poll the network until the asynchronous process is finished.
+    //
+    while (!IsAddressOk) {
+      Ip6->Poll (Ip6);
+    }
+    //
+    // Check whether the Ip6 Address setting is successed.
+    //
+    DataSize = 0;
+    Status = Ip6Cfg->GetData (
+                       Ip6Cfg,
+                       Ip6ConfigDataTypeManualAddress,
+                       &DataSize,
+                       NULL
+                       );
+    if (Status != EFI_BUFFER_TOO_SMALL || DataSize == 0) {
+      Status = EFI_DEVICE_ERROR;
+      goto ON_EXIT;
+    }
+    
+    Ip6Addr = AllocatePool (DataSize);
+    if (Ip6Addr == NULL) {
+      return EFI_OUT_OF_RESOURCES;
+    }
+    Status = Ip6Cfg->GetData (
+                       Ip6Cfg,
+                       Ip6ConfigDataTypeManualAddress,
+                       &DataSize,
+                       (VOID *) Ip6Addr
+                       );
+    if (EFI_ERROR (Status)) {
+      Status = EFI_DEVICE_ERROR;
+      goto ON_EXIT;
+    }
+
+    for (Index = 0; Index < DataSize / sizeof (EFI_IPv6_ADDRESS); Index ++) {
+      if (CompareMem (Ip6Addr + Index, &CfgAddr, sizeof (EFI_IPv6_ADDRESS)) == 
0) {
+        break;
+      }
+    }
+    if (Index == DataSize / sizeof (EFI_IPv6_ADDRESS)) {
+      Status = EFI_ABORTED;
+      goto ON_EXIT;
+    } 
+  }
+    
+ON_EXIT:
+  if (MappedEvt != NULL) {
+    Ip6Cfg->UnregisterDataNotify (
+              Ip6Cfg,
+              Ip6ConfigDataTypeManualAddress,
+              MappedEvt
+              );
+    gBS->CloseEvent (MappedEvt);
+  }
+
+  if (Ip6Addr != NULL) {
+    FreePool (Ip6Addr);
+  }
+  
+  return Status;    
+}
+
+/**
+  Start the S.A.R.R DHCPv6 process to acquire the IPv6 address and other Http 
boot information.
+
+  @param[in]  Private           Pointer to HTTP_BOOT private data.
+
+  @retval EFI_SUCCESS           The S.A.R.R process successfully finished.
+  @retval Others                Failed to finish the S.A.R.R process.
+
+**/
+EFI_STATUS
+HttpBootDhcp6Sarr (
+  IN HTTP_BOOT_PRIVATE_DATA         *Private
+  )
+{
+  EFI_DHCP6_PROTOCOL               *Dhcp6;
+  EFI_DHCP6_CONFIG_DATA            Config;
+  EFI_DHCP6_MODE_DATA              Mode;
+  EFI_DHCP6_RETRANSMISSION         *Retransmit;
+  EFI_DHCP6_PACKET_OPTION          *OptList[HTTP_BOOT_DHCP6_OPTION_MAX_NUM];
+  UINT32                           OptCount;
+  UINT8                            Buffer[HTTP_BOOT_DHCP6_OPTION_MAX_SIZE];
+  EFI_STATUS                       Status;
+
+  Dhcp6 = Private->Dhcp6;
+  ASSERT (Dhcp6 != NULL);
+
+  //
+  // Build options list for the request packet.
+  //
+  OptCount = HttpBootBuildDhcp6Options (Private, OptList, Buffer);
+  ASSERT (OptCount >0);
+  
+  Retransmit = AllocateZeroPool (sizeof (EFI_DHCP6_RETRANSMISSION));
+  if (Retransmit == NULL) {
+    return EFI_OUT_OF_RESOURCES;
+  }
+  
+  ZeroMem (&Mode, sizeof (EFI_DHCP6_MODE_DATA));
+  ZeroMem (&Config, sizeof (EFI_DHCP6_CONFIG_DATA));
+  
+  Config.OptionCount           = OptCount;
+  Config.OptionList            = OptList;
+  Config.Dhcp6Callback         = HttpBootDhcp6CallBack;
+  Config.CallbackContext       = Private;
+  Config.IaInfoEvent           = NULL;
+  Config.RapidCommit           = FALSE;
+  Config.ReconfigureAccept     = FALSE;
+  Config.IaDescriptor.IaId     = NET_RANDOM (NetRandomInitSeed ());
+  Config.IaDescriptor.Type     = EFI_DHCP6_IA_TYPE_NA;
+  Config.SolicitRetransmission = Retransmit;
+  Retransmit->Irt              = 4;
+  Retransmit->Mrc              = 4;
+  Retransmit->Mrt              = 32;
+  Retransmit->Mrd              = 60;
+  
+  //
+  // Configure the DHCPv6 instance for HTTP boot.
+  //
+  Status = Dhcp6->Configure (Dhcp6, &Config);
+  FreePool (Retransmit);
+  if (EFI_ERROR (Status)) {
+    goto ON_EXIT;
+  }
+  //
+  // Initialize the record fields for DHCPv6 offer in private data.
+  //
+  Private->OfferNum      = 0;
+  Private->SelectIndex   = 0;
+  ZeroMem (Private->OfferCount, sizeof (Private->OfferCount));
+  ZeroMem (Private->OfferIndex, sizeof (Private->OfferIndex));
+  
+  //
+  // Start DHCPv6 S.A.R.R. process to acquire IPv6 address.
+  //
+  Status = Dhcp6->Start (Dhcp6);
+  if (EFI_ERROR (Status)) {
+    goto ON_EXIT;
+  }
+  
+  //
+  // Get the acquired IPv6 address and store them.
+  //
+  Status = Dhcp6->GetModeData (Dhcp6, &Mode, NULL);
+  if (EFI_ERROR (Status)) {
+    goto ON_EXIT;
+  }
+  
+  ASSERT (Mode.Ia->State == Dhcp6Bound);
+  CopyMem (&Private->StationIp.v6, &Mode.Ia->IaAddress[0].IpAddress, sizeof 
(EFI_IPv6_ADDRESS));
+  
+  AsciiPrint ("\n  Station IPv6 address is ");
+  HttpBootShowIp6Addr (&Private->StationIp.v6);
+  AsciiPrint ("\n");
+  
+ON_EXIT:
+  if (EFI_ERROR (Status)) {
+    Dhcp6->Stop (Dhcp6);
+    Dhcp6->Configure (Dhcp6, NULL);
+  } else {
+    ZeroMem (&Config, sizeof (EFI_DHCP6_CONFIG_DATA));
+    ZeroMem (&Mode, sizeof (EFI_DHCP6_MODE_DATA));
+    Dhcp6->Configure (Dhcp6, &Config);
+  }
+
+  return Status; 
+    
+}
+

Added: trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDhcp6.h
===================================================================
--- trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDhcp6.h                           
(rev 0)
+++ trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDhcp6.h   2015-11-09 03:30:42 UTC 
(rev 18743)
@@ -0,0 +1,198 @@
+/** @file
+  Functions declaration related with DHCPv6 for HTTP boot driver.
+
+Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available 
under 
+the terms and conditions of the BSD License that accompanies this 
distribution.  
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.                                
          
+    
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,          
           
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+
+#ifndef __EFI_HTTP_BOOT_DHCP6_H__
+#define __EFI_HTTP_BOOT_DHCP6_H__
+
+#define HTTP_BOOT_OFFER_MAX_NUM                16
+#define HTTP_BOOT_DHCP6_OPTION_MAX_NUM         16
+#define HTTP_BOOT_DHCP6_OPTION_MAX_SIZE        312
+#define HTTP_BOOT_DHCP6_PACKET_MAX_SIZE        1472
+#define HTTP_BOOT_IP6_ROUTE_TABLE_TIMEOUT      10
+#define HTTP_BOOT_DEFAULT_HOPLIMIT             64
+#define HTTP_BOOT_DEFAULT_LIFETIME             50000
+
+
+#define HTTP_BOOT_DHCP6_OPT_CLIENT_ID         1
+#define HTTP_BOOT_DHCP6_OPT_SERVER_ID         2
+#define HTTP_BOOT_DHCP6_OPT_IA_NA             3
+#define HTTP_BOOT_DHCP6_OPT_IA_TA             4
+#define HTTP_BOOT_DHCP6_OPT_IAADDR            5
+#define HTTP_BOOT_DHCP6_OPT_ORO               6
+#define HTTP_BOOT_DHCP6_OPT_PREFERENCE        7
+#define HTTP_BOOT_DHCP6_OPT_ELAPSED_TIME      8
+#define HTTP_BOOT_DHCP6_OPT_REPLAY_MSG        9
+#define HTTP_BOOT_DHCP6_OPT_AUTH              11
+#define HTTP_BOOT_DHCP6_OPT_UNICAST           12
+#define HTTP_BOOT_DHCP6_OPT_STATUS_CODE       13
+#define HTTP_BOOT_DHCP6_OPT_RAPID_COMMIT      14
+#define HTTP_BOOT_DHCP6_OPT_USER_CLASS        15
+#define HTTP_BOOT_DHCP6_OPT_VENDOR_CLASS      16
+#define HTTP_BOOT_DHCP6_OPT_VENDOR_OPTS       17
+#define HTTP_BOOT_DHCP6_OPT_INTERFACE_ID      18
+#define HTTP_BOOT_DHCP6_OPT_RECONFIG_MSG      19
+#define HTTP_BOOT_DHCP6_OPT_RECONFIG_ACCEPT   20
+#define HTTP_BOOT_DHCP6_OPT_DNS_SERVERS       23
+#define HTTP_BOOT_DHCP6_OPT_BOOT_FILE_URL     59    // Assigned by IANA, RFC 
5970
+#define HTTP_BOOT_DHCP6_OPT_BOOT_FILE_PARAM   60    // Assigned by IANA, RFC 
5970
+#define HTTP_BOOT_DHCP6_OPT_ARCH              61    // Assigned by IANA, RFC 
5970
+#define HTTP_BOOT_DHCP6_OPT_UNDI              62    // Assigned by IANA, RFC 
5970
+#define HTTP_BOOT_DHCP6_ENTERPRISE_NUM        343   // TODO: IANA TBD: 
temporarily using Intel's
+#define HTTP_BOOT_DHCP6_MAX_BOOT_FILE_SIZE    65535 //   It's a limitation of 
bit length, 65535*512 bytes.
+
+#define HTTP_BOOT_DHCP6_IDX_IA_NA             0
+#define HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL     1
+#define HTTP_BOOT_DHCP6_IDX_BOOT_FILE_PARAM   2
+#define HTTP_BOOT_DHCP6_IDX_VENDOR_CLASS      3
+#define HTTP_BOOT_DHCP6_IDX_DNS_SERVER        4
+#define HTTP_BOOT_DHCP6_IDX_MAX               5
+
+#pragma pack(1)
+typedef struct {
+  UINT16 OpCode[256];
+} HTTP_BOOT_DHCP6_OPTION_ORO;
+
+typedef struct {
+  UINT8 Type;
+  UINT8 MajorVer;
+  UINT8 MinorVer;
+} HTTP_BOOT_DHCP6_OPTION_UNDI;
+
+typedef struct {
+  UINT16 Type;
+} HTTP_BOOT_DHCP6_OPTION_ARCH;
+
+typedef struct {
+  UINT8 ClassIdentifier[10];
+  UINT8 ArchitecturePrefix[5];
+  UINT8 ArchitectureType[5];
+  UINT8 Lit3[1];
+  UINT8 InterfaceName[4];
+  UINT8 Lit4[1];
+  UINT8 UndiMajor[3];
+  UINT8 UndiMinor[3];
+} HTTP_BOOT_CLASS_ID;
+
+typedef struct {
+  UINT32             Vendor;
+  UINT16             ClassLen;
+  HTTP_BOOT_CLASS_ID ClassId;
+} HTTP_BOOT_DHCP6_OPTION_VENDOR_CLASS;
+
+#pragma pack()
+
+typedef union {
+  HTTP_BOOT_DHCP6_OPTION_ORO            *Oro;
+  HTTP_BOOT_DHCP6_OPTION_UNDI           *Undi;
+  HTTP_BOOT_DHCP6_OPTION_ARCH           *Arch;
+  HTTP_BOOT_DHCP6_OPTION_VENDOR_CLASS   *VendorClass;
+} HTTP_BOOT_DHCP6_OPTION_ENTRY;
+
+typedef union {
+  EFI_DHCP6_PACKET        Offer;
+  EFI_DHCP6_PACKET        Ack;
+  UINT8                   Buffer[HTTP_BOOT_DHCP6_PACKET_MAX_SIZE];
+} HTTP_BOOT_DHCP6_PACKET;
+
+typedef struct {
+  HTTP_BOOT_DHCP6_PACKET      Packet;
+  HTTP_BOOT_OFFER_TYPE        OfferType;
+  EFI_DHCP6_PACKET_OPTION     *OptList[HTTP_BOOT_DHCP6_IDX_MAX];
+  VOID                        *UriParser;
+} HTTP_BOOT_DHCP6_PACKET_CACHE;
+
+#define GET_NEXT_DHCP6_OPTION(Opt) \
+  (EFI_DHCP6_PACKET_OPTION *) ((UINT8 *) (Opt) + \
+  sizeof (EFI_DHCP6_PACKET_OPTION) + (NTOHS ((Opt)->OpLen)) - 1)
+
+#define GET_DHCP6_OPTION_SIZE(Pkt)  \
+  ((Pkt)->Length - sizeof (EFI_DHCP6_HEADER))
+
+/**
+  Start the S.A.R.R DHCPv6 process to acquire the IPv6 address and other Http 
boot information.
+
+  @param[in]  Private           Pointer to HTTP_BOOT private data.
+
+  @retval EFI_SUCCESS           The S.A.R.R process successfully finished.
+  @retval Others                Failed to finish the S.A.R.R process.
+
+**/
+EFI_STATUS
+HttpBootDhcp6Sarr (
+  IN HTTP_BOOT_PRIVATE_DATA         *Private
+  );
+
+/**
+  Set the IP6 policy to Automatic.
+
+  @param[in]  Private             The pointer to HTTP_BOOT_PRIVATE_DATA.
+
+  @retval     EFI_SUCCESS         Switch the IP policy succesfully.
+  @retval     Others              Unexpect error happened.
+
+**/
+EFI_STATUS
+HttpBootSetIp6Policy (
+  IN HTTP_BOOT_PRIVATE_DATA        *Private
+  );
+
+/**
+  This function will register the default DNS addresses to the network device.
+  
+  @param[in]  Private             The pointer to HTTP_BOOT_PRIVATE_DATA.
+  @param[in]  DataLength          Size of the buffer pointed to by 
DnsServerData in bytes.
+  @param[in]  DnsServerData       Point a list of DNS server address in an 
array
+                                  of EFI_IPv6_ADDRESS instances.
+
+  @retval     EFI_SUCCESS         The DNS configuration has been configured 
successfully.
+  @retval     Others              Failed to configure the address.
+
+**/
+EFI_STATUS
+HttpBootSetIp6Dns (
+  IN HTTP_BOOT_PRIVATE_DATA         *Private,
+  IN UINTN                          DataLength,
+  IN VOID                           *DnsServerData
+  );
+
+/**
+  This function will register the IPv6 gateway address to the network device.
+  
+  @param[in]  Private             The pointer to HTTP_BOOT_PRIVATE_DATA.
+
+  @retval     EFI_SUCCESS         The new IP configuration has been configured 
successfully.
+  @retval     Others              Failed to configure the address.
+
+**/
+EFI_STATUS
+HttpBootSetIp6Gateway (
+  IN HTTP_BOOT_PRIVATE_DATA         *Private
+  );
+
+/**
+  This function will register the station IP address.
+  
+  @param[in]  Private             The pointer to HTTP_BOOT_PRIVATE_DATA.
+
+  @retval     EFI_SUCCESS         The new IP address has been configured 
successfully.
+  @retval     Others              Failed to configure the address.
+
+**/
+EFI_STATUS
+HttpBootSetIp6Address (
+  IN HTTP_BOOT_PRIVATE_DATA         *Private
+  );
+
+#endif

Modified: trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDxe.c
===================================================================
--- trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDxe.c     2015-11-09 02:29:31 UTC 
(rev 18742)
+++ trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDxe.c     2015-11-09 03:30:42 UTC 
(rev 18743)
@@ -26,6 +26,15 @@
   NULL
 };
 
+EFI_DRIVER_BINDING_PROTOCOL gHttpBootIp6DxeDriverBinding = {
+  HttpBootIp6DxeDriverBindingSupported,
+  HttpBootIp6DxeDriverBindingStart,
+  HttpBootIp6DxeDriverBindingStop,
+  HTTP_BOOT_DXE_VERSION,
+  NULL,
+  NULL
+};
+
 /**
   Destroy the HTTP child based on IPv4 stack.
 
@@ -45,11 +54,11 @@
 
   if (Private->Dhcp4Child != NULL) {
     gBS->CloseProtocol (
-          Private->Dhcp4Child,
-          &gEfiDhcp4ProtocolGuid,
-          This->DriverBindingHandle,
-          Private->Controller
-          );
+           Private->Dhcp4Child,
+           &gEfiDhcp4ProtocolGuid,
+           This->DriverBindingHandle,
+           Private->Controller
+           );
 
     NetLibDestroyServiceChild (
       Private->Controller,
@@ -64,26 +73,103 @@
     Private->HttpCreated = FALSE;
   }
 
-  gBS->CloseProtocol (
-         Private->Controller,
-         &gEfiCallerIdGuid,
-         This->DriverBindingHandle,
-         Private->ChildHandle
-         );
+  if (Private->Ip4Nic != NULL) {
+    
+    gBS->CloseProtocol (
+           Private->Controller,
+           &gEfiCallerIdGuid,
+           This->DriverBindingHandle,
+           Private->Ip4Nic->Controller
+           );
+    
+    gBS->UninstallMultipleProtocolInterfaces (
+           Private->Ip4Nic->Controller,
+           &gEfiLoadFileProtocolGuid,
+           &Private->Ip4Nic->LoadFile,
+           &gEfiDevicePathProtocolGuid,
+           Private->Ip4Nic->DevicePath,
+           NULL
+           );
+    FreePool (Private->Ip4Nic);
+    Private->Ip4Nic = NULL;
+  }
 
-  gBS->UninstallMultipleProtocolInterfaces (
-         Private->ChildHandle,
-         &gEfiLoadFileProtocolGuid,
-         &Private->LoadFile,
-         &gEfiDevicePathProtocolGuid,
-         Private->DevicePath,
-         NULL
-         );
+}
 
-  if (Private->DevicePath != NULL) {
-    FreePool (Private->DevicePath);
-    Private->DevicePath = NULL;
+/**
+  Destroy the HTTP child based on IPv6 stack.
+
+  @param[in]  This              Pointer to the EFI_DRIVER_BINDING_PROTOCOL.
+  @param[in]  Private           Pointer to HTTP_BOOT_PRIVATE_DATA.
+
+**/
+VOID
+HttpBootDestroyIp6Children (
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
+  IN HTTP_BOOT_PRIVATE_DATA       *Private
+  )
+{
+  ASSERT (This != NULL);
+  ASSERT (Private != NULL);
+  ASSERT (Private->UsingIpv6 == TRUE);
+  
+  if (Private->Ip6Child != NULL) {
+    gBS->CloseProtocol (
+           Private->Ip6Child,
+           &gEfiIp6ProtocolGuid,
+           This->DriverBindingHandle,
+           Private->Controller
+           );
+
+    NetLibDestroyServiceChild (
+      Private->Controller,
+      This->DriverBindingHandle,
+      &gEfiIp6ServiceBindingProtocolGuid,
+      Private->Ip6Child
+      );
   }
+
+  if (Private->Dhcp6Child != NULL) {
+    gBS->CloseProtocol (
+           Private->Dhcp6Child,
+           &gEfiDhcp6ProtocolGuid,
+           This->DriverBindingHandle,
+           Private->Controller
+           );
+
+    NetLibDestroyServiceChild (
+      Private->Controller,
+      This->DriverBindingHandle,
+      &gEfiDhcp6ServiceBindingProtocolGuid,
+      Private->Dhcp6Child
+      );
+  }
+
+  if (Private->HttpCreated) {
+    HttpIoDestroyIo(&Private->HttpIo);
+    Private->HttpCreated = FALSE;
+  }
+  
+  if (Private->Ip6Nic != NULL) {
+    
+    gBS->CloseProtocol (
+           Private->Controller,
+           &gEfiCallerIdGuid,
+           This->DriverBindingHandle,
+           Private->Ip6Nic->Controller
+           );
+    
+    gBS->UninstallMultipleProtocolInterfaces (
+           Private->Ip6Nic->Controller,
+           &gEfiLoadFileProtocolGuid,
+           &Private->Ip6Nic->LoadFile,
+           &gEfiDevicePathProtocolGuid,
+           Private->Ip6Nic->DevicePath,
+           NULL
+           );
+    FreePool (Private->Ip6Nic);
+    Private->Ip6Nic = NULL;
+  }
 }
 
 /**
@@ -142,37 +228,37 @@
   // Try to open the DHCP4, HTTP4 and Device Path protocol.
   //
   Status = gBS->OpenProtocol (
-                   ControllerHandle,
-                   &gEfiDhcp4ServiceBindingProtocolGuid,
-                   NULL,
-                   This->DriverBindingHandle,
-                   ControllerHandle,
-                   EFI_OPEN_PROTOCOL_TEST_PROTOCOL
-                   );
+                  ControllerHandle,
+                  &gEfiDhcp4ServiceBindingProtocolGuid,
+                  NULL,
+                  This->DriverBindingHandle,
+                  ControllerHandle,
+                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+                  );
   if (EFI_ERROR (Status)) {
     return Status;
   }
 
   Status = gBS->OpenProtocol (
-                   ControllerHandle,
-                   &gEfiHttpServiceBindingProtocolGuid,
-                   NULL,
-                   This->DriverBindingHandle,
-                   ControllerHandle,
-                   EFI_OPEN_PROTOCOL_TEST_PROTOCOL
-                   );
+                  ControllerHandle,
+                  &gEfiHttpServiceBindingProtocolGuid,
+                  NULL,
+                  This->DriverBindingHandle,
+                  ControllerHandle,
+                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+                  );
   if (EFI_ERROR (Status)) {
     return Status;
   }
 
   Status = gBS->OpenProtocol (
-                   ControllerHandle,
-                   &gEfiDevicePathProtocolGuid,
-                   NULL,
-                   This->DriverBindingHandle,
-                   ControllerHandle,
-                   EFI_OPEN_PROTOCOL_TEST_PROTOCOL
-                   );
+                  ControllerHandle,
+                  &gEfiDevicePathProtocolGuid,
+                  NULL,
+                  This->DriverBindingHandle,
+                  ControllerHandle,
+                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+                  );
 
   return Status;
 }
@@ -235,25 +321,83 @@
                   ControllerHandle,
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL
                   );
+
   if (!EFI_ERROR (Status)) {
-    return EFI_ALREADY_STARTED;
+      Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID(Id);
+  } else {
+    //
+    // Initialize the private data structure.
+    //
+    Private = AllocateZeroPool (sizeof (HTTP_BOOT_PRIVATE_DATA));
+    if (Private == NULL) {
+      return EFI_OUT_OF_RESOURCES;
+    }
+    Private->Signature = HTTP_BOOT_PRIVATE_DATA_SIGNATURE;
+    Private->Controller = ControllerHandle;
+    Private->Image = This->ImageHandle;
+    InitializeListHead (&Private->CacheList);
+    //
+    // Get the NII interface if it exists, it's not required.
+    //
+    Status = gBS->OpenProtocol (
+                    ControllerHandle,
+                    &gEfiNetworkInterfaceIdentifierProtocolGuid_31,
+                    (VOID **) &Private->Nii,
+                    This->DriverBindingHandle,
+                    ControllerHandle,
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL
+                    );
+    if (EFI_ERROR (Status)) {
+      Private->Nii = NULL;
+    }
+
+    //
+    // Open Device Path Protocol to prepare for appending IP and URI node.
+    //
+    Status = gBS->OpenProtocol (
+                    ControllerHandle,
+                    &gEfiDevicePathProtocolGuid,
+                    (VOID **) &Private->ParentDevicePath,
+                    This->DriverBindingHandle,
+                    ControllerHandle,
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL
+                    );
+    if (EFI_ERROR (Status)) {
+      goto ON_ERROR;
+    }
+
+    //
+    // Install a protocol with Caller Id Guid to the NIC, this is just to 
build the relationship between
+    // NIC handle and the private data.
+    //
+    Status = gBS->InstallProtocolInterface (
+                    &ControllerHandle,
+                    &gEfiCallerIdGuid,
+                    EFI_NATIVE_INTERFACE,
+                    &Private->Id
+                    );
+    if (EFI_ERROR (Status)) {
+      goto ON_ERROR;
+    }
+      
   }
-
-  //
-  // Initialize the private data structure.
-  //
-  Private = AllocateZeroPool (sizeof (HTTP_BOOT_PRIVATE_DATA));
-  if (Private == NULL) {
+  
+  if (Private->Ip4Nic != NULL) {
+    //
+    // Already created before
+    //
+    return EFI_SUCCESS;
+  }
+  
+  Private->Ip4Nic = AllocateZeroPool (sizeof (HTTP_BOOT_VIRTUAL_NIC));
+  if (Private->Ip4Nic == NULL) {
     return EFI_OUT_OF_RESOURCES;
   }
-  Private->Signature = HTTP_BOOT_PRIVATE_DATA_SIGNATURE;
-  Private->Controller = ControllerHandle;
-  Private->Image = This->ImageHandle;
-  Private->UsingIpv6 = FALSE;
-  InitializeListHead (&Private->CacheList);
-
+  Private->Ip4Nic->Private   = Private;
+  Private->Ip4Nic->Signature = HTTP_BOOT_VIRTUAL_NIC_SIGNATURE;
+  
   //
-  // Create DHCP child instance.
+  // Create DHCP4 child instance.
   //
   Status = NetLibCreateServiceChild (
              ControllerHandle,
@@ -264,7 +408,7 @@
   if (EFI_ERROR (Status)) {
     goto ON_ERROR;
   }
-
+  
   Status = gBS->OpenProtocol (
                   Private->Dhcp4Child,
                   &gEfiDhcp4ProtocolGuid,
@@ -276,7 +420,7 @@
   if (EFI_ERROR (Status)) {
     goto ON_ERROR;
   }
-
+  
   //
   // Get the Ip4Config2 protocol, it's required to configure the default 
gateway address.
   //
@@ -291,51 +435,503 @@
   if (EFI_ERROR (Status)) {
     goto ON_ERROR;
   }
+  
+  //
+  // Append IPv4 device path node.
+  //
+  Node = AllocateZeroPool (sizeof (IPv4_DEVICE_PATH));
+  if (Node == NULL) {
+    Status = EFI_OUT_OF_RESOURCES;
+    goto ON_ERROR;
+  }
+  Node->Ipv4.Header.Type = MESSAGING_DEVICE_PATH;
+  Node->Ipv4.Header.SubType = MSG_IPv4_DP;
+  SetDevicePathNodeLength (Node, sizeof (IPv4_DEVICE_PATH));
+  Node->Ipv4.StaticIpAddress = FALSE;
+  DevicePath = AppendDevicePathNode (Private->ParentDevicePath, 
(EFI_DEVICE_PATH_PROTOCOL*) Node);
+  FreePool (Node);
+  if (DevicePath == NULL) {
+    Status = EFI_OUT_OF_RESOURCES;
+    goto ON_ERROR;
+  }
+  
+  //
+  // Append URI device path node.
+  //
+  Node = AllocateZeroPool (sizeof (EFI_DEVICE_PATH_PROTOCOL));
+  if (Node == NULL) {
+    Status = EFI_OUT_OF_RESOURCES;
+    goto ON_ERROR;
+  }
+  Node->DevPath.Type = MESSAGING_DEVICE_PATH;
+  Node->DevPath.SubType = MSG_URI_DP;
+  SetDevicePathNodeLength (Node, sizeof (EFI_DEVICE_PATH_PROTOCOL));
+  Private->Ip4Nic->DevicePath = AppendDevicePathNode (DevicePath, 
(EFI_DEVICE_PATH_PROTOCOL*) Node);
+  FreePool (Node);
+  FreePool (DevicePath);
+  if (Private->Ip4Nic->DevicePath == NULL) {
+    Status = EFI_OUT_OF_RESOURCES;
+    goto ON_ERROR;
+  }
+  
+  //
+  // Create a child handle for the HTTP boot and install DevPath and Load file 
protocol on it.
+  //
+  CopyMem (&Private->Ip4Nic->LoadFile, &gHttpBootDxeLoadFile, sizeof 
(EFI_LOAD_FILE_PROTOCOL));
+  Status = gBS->InstallMultipleProtocolInterfaces (
+                  &Private->Ip4Nic->Controller,
+                  &gEfiLoadFileProtocolGuid,
+                  &Private->Ip4Nic->LoadFile,
+                  &gEfiDevicePathProtocolGuid,
+                  Private->Ip4Nic->DevicePath,
+                  NULL
+                  );
+  if (EFI_ERROR (Status)) {
+    goto ON_ERROR;
+  }
+  
+  //
+  // Open the Caller Id child to setup a parent-child relationship between
+  // real NIC handle and the HTTP boot Ipv4 NIC handle.
+  //
+  Status = gBS->OpenProtocol (
+                  ControllerHandle,
+                  &gEfiCallerIdGuid,
+                  (VOID **) &Id,
+                  This->DriverBindingHandle,
+                  Private->Ip4Nic->Controller,
+                  EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
+                  );
+  if (EFI_ERROR (Status)) {
+    goto ON_ERROR;
+  }
+  
+  return EFI_SUCCESS;
 
+    
+ON_ERROR:
+  
+  HttpBootDestroyIp4Children (This, Private);
+  FreePool (Private);
+
+  return Status;
+}
+
+
+/**
+  Stops a device controller or a bus controller.
+  
+  The Stop() function is designed to be invoked from the EFI boot service 
DisconnectController(). 
+  As a result, much of the error checking on the parameters to Stop() has been 
moved 
+  into this common boot service. It is legal to call Stop() from other 
locations, 
+  but the following calling restrictions must be followed, or the system 
behavior will not be deterministic.
+  1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous 
call to this
+     same driver's Start() function.
+  2. The first NumberOfChildren handles of ChildHandleBuffer must all be a 
valid
+     EFI_HANDLE. In addition, all of these handles must have been created in 
this driver's
+     Start() function, and the Start() function must have called 
OpenProtocol() on
+     ControllerHandle with an Attribute of 
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
+  
+  @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL 
instance.
+  @param[in]  ControllerHandle  A handle to the device being stopped. The 
handle must 
+                                support a bus specific I/O protocol for the 
driver 
+                                to use to stop the device.
+  @param[in]  NumberOfChildren  The number of child device handles in 
ChildHandleBuffer.
+  @param[in]  ChildHandleBuffer An array of child handles to be freed. May be 
NULL 
+                                if NumberOfChildren is 0.
+
+  @retval EFI_SUCCESS           The device was stopped.
+  @retval EFI_DEVICE_ERROR      The device could not be stopped due to a 
device error.
+
+**/
+EFI_STATUS
+EFIAPI
+HttpBootIp4DxeDriverBindingStop (
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
+  IN EFI_HANDLE                   ControllerHandle,
+  IN UINTN                        NumberOfChildren,
+  IN EFI_HANDLE                   *ChildHandleBuffer OPTIONAL
+  )
+{
+  EFI_STATUS                      Status;
+  EFI_LOAD_FILE_PROTOCOL          *LoadFile;
+  HTTP_BOOT_PRIVATE_DATA          *Private;
+  EFI_HANDLE                      NicHandle;
+  UINT32                          *Id;
+
   //
-  // Get the NII interface if it exists, it's not required.
+  // Try to get the Load File Protocol from the controller handle.
   //
   Status = gBS->OpenProtocol (
                   ControllerHandle,
-                  &gEfiNetworkInterfaceIdentifierProtocolGuid_31,
-                  (VOID **) &Private->Nii,
+                  &gEfiLoadFileProtocolGuid,
+                  (VOID **) &LoadFile,
                   This->DriverBindingHandle,
                   ControllerHandle,
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL
                   );
   if (EFI_ERROR (Status)) {
-    Private->Nii = NULL;
+    //
+    // If failed, try to find the NIC handle for this controller.
+    //
+    NicHandle = HttpBootGetNicByIp4Children (ControllerHandle);
+    if (NicHandle == NULL) {
+      return EFI_SUCCESS;
+    }
+
+    //
+    // Try to retrieve the private data by the Caller Id Guid.
+    //
+    Status = gBS->OpenProtocol (
+                    NicHandle,
+                    &gEfiCallerIdGuid,
+                    (VOID **) &Id,
+                    This->DriverBindingHandle,
+                    ControllerHandle,
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL
+                    );
+    if (EFI_ERROR (Status)) {
+      return Status;
+    }
+    Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID (Id);
+  } else {
+    Private = HTTP_BOOT_PRIVATE_DATA_FROM_LOADFILE (LoadFile);
+    NicHandle = Private->Controller;
   }
 
   //
-  // Open Device Path Protocol to prepare for appending IP and URI node.
+  // Disable the HTTP boot function.
   //
+  Status = HttpBootStop (Private);
+  if (Status != EFI_SUCCESS && Status != EFI_NOT_STARTED) {
+    return Status;
+  }
+
+  //
+  // Destory all child instance and uninstall protocol interface.
+  //
+  HttpBootDestroyIp4Children (This, Private);
+  
+  if (Private->Ip4Nic == NULL && Private->Ip6Nic == NULL) {
+    //
+    // Release the cached data.
+    //
+    HttpBootFreeCacheList (Private);
+    
+    gBS->UninstallProtocolInterface (
+           NicHandle,
+           &gEfiCallerIdGuid,
+           &Private->Id
+           );
+    FreePool (Private);
+
+  }
+
+  return EFI_SUCCESS;
+}
+
+/**
+  Tests to see if this driver supports a given controller. If a child device 
is provided, 
+  it further tests to see if this driver supports creating a handle for the 
specified child device.
+
+  This function checks to see if the driver specified by This supports the 
device specified by 
+  ControllerHandle. Drivers will typically use the device path attached to 
+  ControllerHandle and/or the services from the bus I/O abstraction attached 
to 
+  ControllerHandle to determine if the driver supports ControllerHandle. This 
function 
+  may be called many times during platform initialization. In order to reduce 
boot times, the tests 
+  performed by this function must be very small, and take as little time as 
possible to execute. This 
+  function must not change the state of any hardware devices, and this 
function must be aware that the 
+  device specified by ControllerHandle may already be managed by the same 
driver or a 
+  different driver. This function must match its calls to AllocatePages() with 
FreePages(), 
+  AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().  
+  Because ControllerHandle may have been previously started by the same 
driver, if a protocol is 
+  already in the opened state, then it must not be closed with 
CloseProtocol(). This is required 
+  to guarantee the state of ControllerHandle is not modified by this function.
+
+  @param[in]  This                 A pointer to the 
EFI_DRIVER_BINDING_PROTOCOL instance.
+  @param[in]  ControllerHandle     The handle of the controller to test. This 
handle 
+                                   must support a protocol interface that 
supplies 
+                                   an I/O abstraction to the driver.
+  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a 
device path.  This 
+                                   parameter is ignored by device drivers, and 
is optional for bus 
+                                   drivers. For bus drivers, if this parameter 
is not NULL, then 
+                                   the bus driver must determine if the bus 
controller specified 
+                                   by ControllerHandle and the child 
controller specified 
+                                   by RemainingDevicePath are both supported 
by this 
+                                   bus driver.
+
+  @retval EFI_SUCCESS              The device specified by ControllerHandle and
+                                   RemainingDevicePath is supported by the 
driver specified by This.
+  @retval EFI_ALREADY_STARTED      The device specified by ControllerHandle and
+                                   RemainingDevicePath is already being 
managed by the driver
+                                   specified by This.
+  @retval EFI_ACCESS_DENIED        The device specified by ControllerHandle and
+                                   RemainingDevicePath is already being 
managed by a different
+                                   driver or an application that requires 
exclusive access.
+                                   Currently not implemented.
+  @retval EFI_UNSUPPORTED          The device specified by ControllerHandle and
+                                   RemainingDevicePath is not supported by the 
driver specified by This.
+**/
+EFI_STATUS
+EFIAPI
+HttpBootIp6DxeDriverBindingSupported (
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
+  IN EFI_HANDLE                   ControllerHandle,
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
+  )
+{
+  EFI_STATUS                    Status;
+  
+  //
+  // Try to open the DHCP6, HTTP and Device Path protocol.
+  //
   Status = gBS->OpenProtocol (
                   ControllerHandle,
+                  &gEfiDhcp6ServiceBindingProtocolGuid,
+                  NULL,
+                  This->DriverBindingHandle,
+                  ControllerHandle,
+                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+                  );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  Status = gBS->OpenProtocol (
+                  ControllerHandle,
+                  &gEfiHttpServiceBindingProtocolGuid,
+                  NULL,
+                  This->DriverBindingHandle,
+                  ControllerHandle,
+                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+                  );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  Status = gBS->OpenProtocol (
+                  ControllerHandle,
                   &gEfiDevicePathProtocolGuid,
-                  (VOID **) &Private->ParentDevicePath,
+                  NULL,
                   This->DriverBindingHandle,
                   ControllerHandle,
+                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+                  );
+
+  return Status;
+
+}
+
+/**
+  Starts a device controller or a bus controller.
+
+  The Start() function is designed to be invoked from the EFI boot service 
ConnectController().
+  As a result, much of the error checking on the parameters to Start() has 
been moved into this 
+  common boot service. It is legal to call Start() from other locations, 
+  but the following calling restrictions must be followed, or the system 
behavior will not be deterministic.
+  1. ControllerHandle must be a valid EFI_HANDLE.
+  2. If RemainingDevicePath is not NULL, then it must be a pointer to a 
naturally aligned
+     EFI_DEVICE_PATH_PROTOCOL.
+  3. Prior to calling Start(), the Supported() function for the driver 
specified by This must
+     have been called with the same calling parameters, and Supported() must 
have returned EFI_SUCCESS.  
+
+  @param[in]  This                 A pointer to the 
EFI_DRIVER_BINDING_PROTOCOL instance.
+  @param[in]  ControllerHandle     The handle of the controller to start. This 
handle 
+                                   must support a protocol interface that 
supplies 
+                                   an I/O abstraction to the driver.
+  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a 
device path.  This 
+                                   parameter is ignored by device drivers, and 
is optional for bus 
+                                   drivers. For a bus driver, if this 
parameter is NULL, then handles 
+                                   for all the children of Controller are 
created by this driver.  
+                                   If this parameter is not NULL and the first 
Device Path Node is 
+                                   not the End of Device Path Node, then only 
the handle for the 
+                                   child device specified by the first Device 
Path Node of 
+                                   RemainingDevicePath is created by this 
driver.
+                                   If the first Device Path Node of 
RemainingDevicePath is 
+                                   the End of Device Path Node, no child 
handle is created by this
+                                   driver.
+
+  @retval EFI_SUCCESS              The device was started.
+  @retval EFI_DEVICE_ERROR         The device could not be started due to a 
device error.Currently not implemented.
+  @retval EFI_OUT_OF_RESOURCES     The request could not be completed due to a 
lack of resources.
+  @retval Others                   The driver failded to start the device.
+
+**/
+EFI_STATUS
+EFIAPI
+HttpBootIp6DxeDriverBindingStart (
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
+  IN EFI_HANDLE                   ControllerHandle,
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
+  )
+{
+  EFI_STATUS                 Status;
+  HTTP_BOOT_PRIVATE_DATA     *Private;
+  EFI_DEV_PATH               *Node;
+  EFI_DEVICE_PATH_PROTOCOL   *DevicePath;
+  UINT32                     *Id;
+  
+  Status = gBS->OpenProtocol (
+                  ControllerHandle,
+                  &gEfiCallerIdGuid,
+                  (VOID **) &Id,
+                  This->DriverBindingHandle,
+                  ControllerHandle,
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL
                   );
+  
+  if (!EFI_ERROR (Status)) {
+      Private = HTTP_BOOT_PRIVATE_DATA_FROM_ID(Id);
+  } else {
+    //
+    // Initialize the private data structure.
+    //
+    Private = AllocateZeroPool (sizeof (HTTP_BOOT_PRIVATE_DATA));
+    if (Private == NULL) {
+      return EFI_OUT_OF_RESOURCES;
+    }
+    Private->Signature = HTTP_BOOT_PRIVATE_DATA_SIGNATURE;
+    Private->Controller = ControllerHandle;
+    Private->Image = This->ImageHandle;
+    InitializeListHead (&Private->CacheList);
+    //
+    // Get the NII interface if it exists, it's not required.
+    //
+    Status = gBS->OpenProtocol (
+                    ControllerHandle,
+                    &gEfiNetworkInterfaceIdentifierProtocolGuid_31,
+                    (VOID **) &Private->Nii,
+                    This->DriverBindingHandle,
+                    ControllerHandle,
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL
+                    );
+    if (EFI_ERROR (Status)) {
+      Private->Nii = NULL;
+    }
+
+    //
+    // Open Device Path Protocol to prepare for appending IP and URI node.
+    //
+    Status = gBS->OpenProtocol (
+                    ControllerHandle,
+                    &gEfiDevicePathProtocolGuid,
+                    (VOID **) &Private->ParentDevicePath,
+                    This->DriverBindingHandle,
+                    ControllerHandle,
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL
+                    );
+    if (EFI_ERROR (Status)) {
+      goto ON_ERROR;
+    }
+
+    //
+    // Install a protocol with Caller Id Guid to the NIC, this is just to 
build the relationship between
+    // NIC handle and the private data.
+    //
+    Status = gBS->InstallProtocolInterface (
+                    &ControllerHandle,
+                    &gEfiCallerIdGuid,
+                    EFI_NATIVE_INTERFACE,
+                    &Private->Id
+                    );
+    if (EFI_ERROR (Status)) {
+      goto ON_ERROR;
+    }
+      
+  }
+  
+  if (Private->Ip6Nic != NULL) {
+    //
+    // Already created before
+    //
+    return EFI_SUCCESS;
+  }
+  
+  Private->Ip6Nic = AllocateZeroPool (sizeof (HTTP_BOOT_VIRTUAL_NIC));
+  if (Private->Ip6Nic == NULL) {
+    return EFI_OUT_OF_RESOURCES;
+  }
+  Private->Ip6Nic->Private   = Private;
+  Private->Ip6Nic->Signature = HTTP_BOOT_VIRTUAL_NIC_SIGNATURE;
+
+  //
+  // Create Dhcp6 child and open Dhcp6 protocol
+  Status = NetLibCreateServiceChild (
+             ControllerHandle,
+             This->DriverBindingHandle,
+             &gEfiDhcp6ServiceBindingProtocolGuid,
+             &Private->Dhcp6Child
+             );
   if (EFI_ERROR (Status)) {
     goto ON_ERROR;
   }
 
+  Status = gBS->OpenProtocol (
+                  Private->Dhcp6Child,
+                  &gEfiDhcp6ProtocolGuid,
+                  (VOID **) &Private->Dhcp6,
+                  This->DriverBindingHandle,
+                  ControllerHandle,
+                  EFI_OPEN_PROTOCOL_BY_DRIVER
+                  );
+  if (EFI_ERROR (Status)) {
+    goto ON_ERROR;
+  }
+
   //
-  // Append IPv4 device path node.
+  // Create Ip6 child and open Ip6 protocol for background ICMP packets.
   //
-  Node = AllocateZeroPool (sizeof (IPv4_DEVICE_PATH));
+  Status = NetLibCreateServiceChild (
+              ControllerHandle,
+              This->DriverBindingHandle,
+              &gEfiIp6ServiceBindingProtocolGuid,
+              &Private->Ip6Child
+              );
+  if (EFI_ERROR (Status)) {
+    goto ON_ERROR;
+  }
+
+  Status = gBS->OpenProtocol (
+                  Private->Ip6Child,
+                  &gEfiIp6ProtocolGuid,
+                  (VOID **) &Private->Ip6,
+                  This->DriverBindingHandle,
+                  ControllerHandle,
+                  EFI_OPEN_PROTOCOL_BY_DRIVER
+                  );
+  if (EFI_ERROR (Status)) {
+    goto ON_ERROR;
+  }
+
+  //
+  // Locate Ip6Config protocol, it's required to configure the default gateway 
address.
+  //
+  Status = gBS->OpenProtocol (
+                  ControllerHandle,
+                  &gEfiIp6ConfigProtocolGuid,
+                  (VOID **) &Private->Ip6Config,
+                  This->DriverBindingHandle,
+                  ControllerHandle,
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL
+                  );
+  if (EFI_ERROR (Status)) {
+    goto ON_ERROR;
+  }
+
+  //
+  // Append IPv6 device path node.
+  //
+  Node = AllocateZeroPool (sizeof (IPv6_DEVICE_PATH));
   if (Node == NULL) {
     Status = EFI_OUT_OF_RESOURCES;
     goto ON_ERROR;
   }
-  Node->Ipv4.Header.Type = MESSAGING_DEVICE_PATH;
-  Node->Ipv4.Header.SubType = MSG_IPv4_DP;
-  SetDevicePathNodeLength (Node, sizeof (IPv4_DEVICE_PATH));
-  Node->Ipv4.StaticIpAddress = FALSE;
-  DevicePath = AppendDevicePathNode (Private->ParentDevicePath, 
(EFI_DEVICE_PATH_PROTOCOL*) Node);
-  FreePool (Node);
+  Node->Ipv6.Header.Type = MESSAGING_DEVICE_PATH;
+  Node->Ipv6.Header.SubType = MSG_IPv6_DP;
+  Node->Ipv6.PrefixLength = IP6_PREFIX_LENGTH;
+  SetDevicePathNodeLength (Node, sizeof (IPv6_DEVICE_PATH));
+  DevicePath = AppendDevicePathNode(Private->ParentDevicePath, 
(EFI_DEVICE_PATH*) Node);
+  FreePool(Node);
   if (DevicePath == NULL) {
     Status = EFI_OUT_OF_RESOURCES;
     goto ON_ERROR;
@@ -352,10 +948,10 @@
   Node->DevPath.Type = MESSAGING_DEVICE_PATH;
   Node->DevPath.SubType = MSG_URI_DP;
   SetDevicePathNodeLength (Node, sizeof (EFI_DEVICE_PATH_PROTOCOL));
-  Private->DevicePath = AppendDevicePathNode (DevicePath, 
(EFI_DEVICE_PATH_PROTOCOL*) Node);
+  Private->Ip6Nic->DevicePath = AppendDevicePathNode (DevicePath, 
(EFI_DEVICE_PATH_PROTOCOL*) Node);
   FreePool (Node);
   FreePool (DevicePath);
-  if (Private->DevicePath == NULL) {
+  if (Private->Ip6Nic->DevicePath == NULL) {
     Status = EFI_OUT_OF_RESOURCES;
     goto ON_ERROR;
   }
@@ -363,13 +959,13 @@
   //
   // Create a child handle for the HTTP boot and install DevPath and Load file 
protocol on it.
   //
-  CopyMem (&Private->LoadFile, &gHttpBootDxeLoadFile, sizeof 
(Private->LoadFile));
+  CopyMem (&Private->Ip6Nic->LoadFile, &gHttpBootDxeLoadFile, sizeof 
(Private->LoadFile));
   Status = gBS->InstallMultipleProtocolInterfaces (
-                  &Private->ChildHandle,
+                  &Private->Ip6Nic->Controller,
                   &gEfiLoadFileProtocolGuid,
-                  &Private->LoadFile,
+                  &Private->Ip6Nic->LoadFile,
                   &gEfiDevicePathProtocolGuid,
-                  Private->DevicePath,
+                  Private->Ip6Nic->DevicePath,
                   NULL
                   );
   if (EFI_ERROR (Status)) {
@@ -377,20 +973,6 @@
   }
 
   //
-  // Install a protocol with Caller Id Guid to the NIC, this is just to build 
the relationship between
-  // NIC handle and the private data.
-  //
-  Status = gBS->InstallProtocolInterface (
-                  &ControllerHandle,
-                  &gEfiCallerIdGuid,
-                  EFI_NATIVE_INTERFACE,
-                  &Private->Id
-                  );
-  if (EFI_ERROR (Status)) {
-    goto ON_ERROR;
-  }
-
-  //
   // Open the Caller Id child to setup a parent-child relationship between
   // real NIC handle and the HTTP boot child handle.
   //
@@ -399,7 +981,7 @@
                   &gEfiCallerIdGuid,
                   (VOID **) &Id,
                   This->DriverBindingHandle,
-                  Private->ChildHandle,
+                  Private->Ip6Nic->Controller,
                   EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
                   );
   if (EFI_ERROR (Status)) {
@@ -407,13 +989,14 @@
   }
 
   return EFI_SUCCESS;
-
+   
 ON_ERROR:
   
-  HttpBootDestroyIp4Children (This, Private);
-  FreePool (Private);
+ HttpBootDestroyIp6Children(This, Private);
+ FreePool (Private);
 
-  return Status;
+ return Status;
+ 
 }
 
 /**
@@ -444,7 +1027,7 @@
 **/
 EFI_STATUS
 EFIAPI
-HttpBootIp4DxeDriverBindingStop (
+HttpBootIp6DxeDriverBindingStop (
   IN EFI_DRIVER_BINDING_PROTOCOL  *This,
   IN EFI_HANDLE                   ControllerHandle,
   IN UINTN                        NumberOfChildren,
@@ -472,7 +1055,7 @@
     //
     // If failed, try to find the NIC handle for this controller.
     //
-    NicHandle = HttpBootGetNicByIp4Children (ControllerHandle);
+    NicHandle = HttpBootGetNicByIp6Children (ControllerHandle);
     if (NicHandle == NULL) {
       return EFI_SUCCESS;
     }
@@ -508,23 +1091,25 @@
   //
   // Destory all child instance and uninstall protocol interface.
   //
-  HttpBootDestroyIp4Children (This, Private);
+  HttpBootDestroyIp6Children (This, Private);
 
-  //
-  // Release the cached data.
-  //
-  HttpBootFreeCacheList (Private);
+  if (Private->Ip4Nic == NULL && Private->Ip6Nic == NULL) {
+    //
+    // Release the cached data.
+    //
+    HttpBootFreeCacheList (Private);
+        
+    gBS->UninstallProtocolInterface (
+           NicHandle,
+           &gEfiCallerIdGuid,
+           &Private->Id
+           );
+    FreePool (Private);
 
-  gBS->UninstallProtocolInterface (
-         NicHandle,
-         &gEfiCallerIdGuid,
-         &Private->Id
-         );
-  FreePool (Private);
+  }
 
   return EFI_SUCCESS;
 }
-
 /**
   This is the declaration of an EFI image entry point. This entry point is
   the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
@@ -544,16 +1129,42 @@
   IN EFI_SYSTEM_TABLE  *SystemTable
   )
 {
+  EFI_STATUS   Status;
   //
   // Install UEFI Driver Model protocol(s).
   //
-  return EfiLibInstallDriverBindingComponentName2 (
+  Status = EfiLibInstallDriverBindingComponentName2 (
+             ImageHandle,
+             SystemTable,
+             &gHttpBootIp4DxeDriverBinding,
+             ImageHandle,
+             &gHttpBootDxeComponentName,
+             &gHttpBootDxeComponentName2
+             );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+  
+  Status = EfiLibInstallDriverBindingComponentName2 (
+             ImageHandle,
+             SystemTable,
+             &gHttpBootIp6DxeDriverBinding,
+             NULL,
+             &gHttpBootDxeComponentName,
+             &gHttpBootDxeComponentName2
+             );
+  if (EFI_ERROR (Status)) {
+    gBS->UninstallMultipleProtocolInterfaces(
            ImageHandle,
-           SystemTable,
+           &gEfiDriverBindingProtocolGuid,
            &gHttpBootIp4DxeDriverBinding,
-           ImageHandle,
+           &gEfiComponentName2ProtocolGuid,
+           &gHttpBootDxeComponentName2,
+           &gEfiComponentNameProtocolGuid,
            &gHttpBootDxeComponentName,
-           &gHttpBootDxeComponentName2
+           NULL
            );
+  }
+  return Status;
 }
 

Modified: trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDxe.h
===================================================================
--- trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDxe.h     2015-11-09 02:29:31 UTC 
(rev 18742)
+++ trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDxe.h     2015-11-09 03:30:42 UTC 
(rev 18743)
@@ -41,9 +41,11 @@
 //
 #include <Protocol/NetworkInterfaceIdentifier.h>
 #include <Protocol/Dhcp4.h>
+#include <Protocol/Dhcp6.h>
+#include <Protocol/Dns6.h>
 #include <Protocol/Http.h>
 #include <Protocol/Ip4Config2.h>
-
+#include <Protocol/Ip6Config.h>
 //
 // Produced Protocols
 //
@@ -65,29 +67,45 @@
 // Private data structure
 //
 typedef struct _HTTP_BOOT_PRIVATE_DATA      HTTP_BOOT_PRIVATE_DATA;
+typedef struct _HTTP_BOOT_VIRTUAL_NIC       HTTP_BOOT_VIRTUAL_NIC;
 
 //
 // Include files with internal function prototypes
 //
 #include "HttpBootComponentName.h"
 #include "HttpBootDhcp4.h"
+#include "HttpBootDhcp6.h"
 #include "HttpBootImpl.h"
 #include "HttpBootSupport.h"
 #include "HttpBootClient.h"
 
 typedef union {
   HTTP_BOOT_DHCP4_PACKET_CACHE              Dhcp4;
+  HTTP_BOOT_DHCP6_PACKET_CACHE              Dhcp6;
 } HTTP_BOOT_DHCP_PACKET_CACHE;
 
+struct _HTTP_BOOT_VIRTUAL_NIC {
+  UINT32                                    Signature;
+  EFI_HANDLE                                Controller;
+  EFI_LOAD_FILE_PROTOCOL                    LoadFile;
+  EFI_DEVICE_PATH_PROTOCOL                  *DevicePath;
+  HTTP_BOOT_PRIVATE_DATA                    *Private;
+};
+
 struct _HTTP_BOOT_PRIVATE_DATA {
   UINT32                                    Signature;
   EFI_HANDLE                                Controller;
   EFI_HANDLE                                Image;
 
+  HTTP_BOOT_VIRTUAL_NIC                     *Ip4Nic;
+  HTTP_BOOT_VIRTUAL_NIC                     *Ip6Nic;
+
   //
   // Cousumed children
   //
+  EFI_HANDLE                                Ip6Child;
   EFI_HANDLE                                Dhcp4Child;
+  EFI_HANDLE                                Dhcp6Child;
   HTTP_IO                                   HttpIo;
   BOOLEAN                                   HttpCreated;
 
@@ -95,14 +113,13 @@
   // Consumed protocol
   //
   EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *Nii;
+  EFI_IP6_PROTOCOL                          *Ip6;
   EFI_IP4_CONFIG2_PROTOCOL                  *Ip4Config2;
+  EFI_IP6_CONFIG_PROTOCOL                   *Ip6Config;
   EFI_DHCP4_PROTOCOL                        *Dhcp4;
+  EFI_DHCP6_PROTOCOL                        *Dhcp6;
   EFI_DEVICE_PATH_PROTOCOL                  *ParentDevicePath;
 
-  //
-  // Produced children
-  //
-  EFI_HANDLE                                ChildHandle;
   
   //
   // Produced protocol
@@ -119,10 +136,12 @@
   EFI_IP_ADDRESS                            StationIp;
   EFI_IP_ADDRESS                            SubnetMask;
   EFI_IP_ADDRESS                            GatewayIp;
+  EFI_IP_ADDRESS                            ServerIp;
   UINT16                                    Port;
   CHAR8                                     *BootFileUri;
   VOID                                      *BootFileUriParser;
   UINTN                                     BootFileSize;
+  BOOLEAN                                   NoGateway;
 
   //
   // Cached HTTP data
@@ -167,9 +186,10 @@
 };
 
 #define HTTP_BOOT_PRIVATE_DATA_SIGNATURE          SIGNATURE_32 ('H', 'B', 'P', 
'D')
+#define HTTP_BOOT_VIRTUAL_NIC_SIGNATURE           SIGNATURE_32 ('H', 'B', 'V', 
'N')
 #define HTTP_BOOT_PRIVATE_DATA_FROM_LOADFILE(a)   CR (a, 
HTTP_BOOT_PRIVATE_DATA, LoadFile, HTTP_BOOT_PRIVATE_DATA_SIGNATURE)
 #define HTTP_BOOT_PRIVATE_DATA_FROM_ID(a)         CR (a, 
HTTP_BOOT_PRIVATE_DATA, Id, HTTP_BOOT_PRIVATE_DATA_SIGNATURE)
-
+#define HTTP_BOOT_VIRTUAL_NIC_FROM_LOADFILE(a)    CR (a, 
HTTP_BOOT_VIRTUAL_NIC, LoadFile, HTTP_BOOT_VIRTUAL_NIC_SIGNATURE)
 extern EFI_LOAD_FILE_PROTOCOL               gHttpBootDxeLoadFile;
 
 /**
@@ -300,4 +320,131 @@
   IN EFI_HANDLE                   *ChildHandleBuffer OPTIONAL
   );
 
+/**
+  Tests to see if this driver supports a given controller. If a child device 
is provided, 
+  it further tests to see if this driver supports creating a handle for the 
specified child device.
+
+  This function checks to see if the driver specified by This supports the 
device specified by 
+  ControllerHandle. Drivers will typically use the device path attached to 
+  ControllerHandle and/or the services from the bus I/O abstraction attached 
to 
+  ControllerHandle to determine if the driver supports ControllerHandle. This 
function 
+  may be called many times during platform initialization. In order to reduce 
boot times, the tests 
+  performed by this function must be very small, and take as little time as 
possible to execute. This 
+  function must not change the state of any hardware devices, and this 
function must be aware that the 
+  device specified by ControllerHandle may already be managed by the same 
driver or a 
+  different driver. This function must match its calls to AllocatePages() with 
FreePages(), 
+  AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().  
+  Because ControllerHandle may have been previously started by the same 
driver, if a protocol is 
+  already in the opened state, then it must not be closed with 
CloseProtocol(). This is required 
+  to guarantee the state of ControllerHandle is not modified by this function.
+
+  @param[in]  This                 A pointer to the 
EFI_DRIVER_BINDING_PROTOCOL instance.
+  @param[in]  ControllerHandle     The handle of the controller to test. This 
handle 
+                                   must support a protocol interface that 
supplies 
+                                   an I/O abstraction to the driver.
+  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a 
device path.  This 
+                                   parameter is ignored by device drivers, and 
is optional for bus 
+                                   drivers. For bus drivers, if this parameter 
is not NULL, then 
+                                   the bus driver must determine if the bus 
controller specified 
+                                   by ControllerHandle and the child 
controller specified 
+                                   by RemainingDevicePath are both supported 
by this 
+                                   bus driver.
+
+  @retval EFI_SUCCESS              The device specified by ControllerHandle and
+                                   RemainingDevicePath is supported by the 
driver specified by This.
+  @retval EFI_ALREADY_STARTED      The device specified by ControllerHandle and
+                                   RemainingDevicePath is already being 
managed by the driver
+                                   specified by This.
+  @retval EFI_ACCESS_DENIED        The device specified by ControllerHandle and
+                                   RemainingDevicePath is already being 
managed by a different
+                                   driver or an application that requires 
exclusive access.
+                                   Currently not implemented.
+  @retval EFI_UNSUPPORTED          The device specified by ControllerHandle and
+                                   RemainingDevicePath is not supported by the 
driver specified by This.
+**/
+EFI_STATUS
+EFIAPI
+HttpBootIp6DxeDriverBindingSupported (
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
+  IN EFI_HANDLE                   ControllerHandle,
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
+  );
+
+/**
+  Starts a device controller or a bus controller.
+
+  The Start() function is designed to be invoked from the EFI boot service 
ConnectController().
+  As a result, much of the error checking on the parameters to Start() has 
been moved into this 
+  common boot service. It is legal to call Start() from other locations, 
+  but the following calling restrictions must be followed, or the system 
behavior will not be deterministic.
+  1. ControllerHandle must be a valid EFI_HANDLE.
+  2. If RemainingDevicePath is not NULL, then it must be a pointer to a 
naturally aligned
+     EFI_DEVICE_PATH_PROTOCOL.
+  3. Prior to calling Start(), the Supported() function for the driver 
specified by This must
+     have been called with the same calling parameters, and Supported() must 
have returned EFI_SUCCESS.  
+
+  @param[in]  This                 A pointer to the 
EFI_DRIVER_BINDING_PROTOCOL instance.
+  @param[in]  ControllerHandle     The handle of the controller to start. This 
handle 
+                                   must support a protocol interface that 
supplies 
+                                   an I/O abstraction to the driver.
+  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a 
device path.  This 
+                                   parameter is ignored by device drivers, and 
is optional for bus 
+                                   drivers. For a bus driver, if this 
parameter is NULL, then handles 
+                                   for all the children of Controller are 
created by this driver.  
+                                   If this parameter is not NULL and the first 
Device Path Node is 
+                                   not the End of Device Path Node, then only 
the handle for the 
+                                   child device specified by the first Device 
Path Node of 
+                                   RemainingDevicePath is created by this 
driver.
+                                   If the first Device Path Node of 
RemainingDevicePath is 
+                                   the End of Device Path Node, no child 
handle is created by this
+                                   driver.
+
+  @retval EFI_SUCCESS              The device was started.
+  @retval EFI_DEVICE_ERROR         The device could not be started due to a 
device error.Currently not implemented.
+  @retval EFI_OUT_OF_RESOURCES     The request could not be completed due to a 
lack of resources.
+  @retval Others                   The driver failded to start the device.
+
+**/
+EFI_STATUS
+EFIAPI
+HttpBootIp6DxeDriverBindingStart (
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
+  IN EFI_HANDLE                   ControllerHandle,
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
+  );
+
+/**
+  Stops a device controller or a bus controller.
+  
+  The Stop() function is designed to be invoked from the EFI boot service 
DisconnectController(). 
+  As a result, much of the error checking on the parameters to Stop() has been 
moved 
+  into this common boot service. It is legal to call Stop() from other 
locations, 
+  but the following calling restrictions must be followed, or the system 
behavior will not be deterministic.
+  1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous 
call to this
+     same driver's Start() function.
+  2. The first NumberOfChildren handles of ChildHandleBuffer must all be a 
valid
+     EFI_HANDLE. In addition, all of these handles must have been created in 
this driver's
+     Start() function, and the Start() function must have called 
OpenProtocol() on
+     ControllerHandle with an Attribute of 
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
+  
+  @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL 
instance.
+  @param[in]  ControllerHandle  A handle to the device being stopped. The 
handle must 
+                                support a bus specific I/O protocol for the 
driver 
+                                to use to stop the device.
+  @param[in]  NumberOfChildren  The number of child device handles in 
ChildHandleBuffer.
+  @param[in]  ChildHandleBuffer An array of child handles to be freed. May be 
NULL 
+                                if NumberOfChildren is 0.
+
+  @retval EFI_SUCCESS           The device was stopped.
+  @retval EFI_DEVICE_ERROR      The device could not be stopped due to a 
device error.
+
+**/
+EFI_STATUS
+EFIAPI
+HttpBootIp6DxeDriverBindingStop (
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
+  IN EFI_HANDLE                   ControllerHandle,
+  IN UINTN                        NumberOfChildren,
+  IN EFI_HANDLE                   *ChildHandleBuffer OPTIONAL
+  );
 #endif

Modified: trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDxe.inf
===================================================================
--- trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDxe.inf   2015-11-09 02:29:31 UTC 
(rev 18742)
+++ trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDxe.inf   2015-11-09 03:30:42 UTC 
(rev 18743)
@@ -35,6 +35,8 @@
   HttpBootImpl.c
   HttpBootDhcp4.h
   HttpBootDhcp4.c
+  HttpBootDhcp6.h
+  HttpBootDhcp6.c
   HttpBootSupport.h
   HttpBootSupport.c
   HttpBootClient.h
@@ -62,6 +64,13 @@
   gEfiDhcp4ServiceBindingProtocolGuid             ## TO_START
   gEfiDhcp4ProtocolGuid                           ## TO_START
   gEfiIp4Config2ProtocolGuid                      ## TO_START
+  gEfiDhcp6ServiceBindingProtocolGuid             ## TO_START
+  gEfiDhcp6ProtocolGuid                           ## TO_START
+  gEfiDns6ServiceBindingProtocolGuid              ## SOMETIMES_CONSUMES
+  gEfiDns6ProtocolGuid                            ## SOMETIMES_CONSUMES
+  gEfiIp6ServiceBindingProtocolGuid               ## TO_START
+  gEfiIp6ProtocolGuid                             ## TO_START
+  gEfiIp6ConfigProtocolGuid                       ## TO_START
   gEfiNetworkInterfaceIdentifierProtocolGuid_31   ## SOMETIMES_CONSUMES
 
 [UserExtensions.TianoCore."ExtraFiles"]

Modified: trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDxe.uni
===================================================================
--- trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDxe.uni   2015-11-09 02:29:31 UTC 
(rev 18742)
+++ trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootDxe.uni   2015-11-09 03:30:42 UTC 
(rev 18743)
@@ -6,7 +6,7 @@
  - @@ -42,7 +42,7 @@
  - 
Modified: trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootImpl.c
===================================================================
--- trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootImpl.c    2015-11-09 02:29:31 UTC 
(rev 18742)
+++ trunk/edk2/NetworkPkg/HttpBootDxe/HttpBootImpl.c    2015-11-09 03:30:42 UTC 
(rev 18743)
@@ -18,6 +18,9 @@
   Enable the use of UEFI HTTP boot function.
 
   @param[in]    Private            The pointer to the driver's private data.
+  @param[in]    UsingIpv6          Specifies the type of IP addresses that are 
to be
+                                   used during the session that is being 
started.
+                                   Set to TRUE for IPv6, and FALSE for IPv4.
 
   @retval EFI_SUCCESS              HTTP boot was successfully enabled.
   @retval EFI_INVALID_PARAMETER    Private is NULL.
@@ -26,10 +29,12 @@
 **/
 EFI_STATUS
 HttpBootStart (
-  IN HTTP_BOOT_PRIVATE_DATA           *Private
+  IN HTTP_BOOT_PRIVATE_DATA           *Private,
+  IN BOOLEAN                          UsingIpv6
   )
 {
-  UINTN          Index;
+  UINTN                Index;
+  EFI_STATUS           Status;
 
   if (Private == NULL) {
     return EFI_INVALID_PARAMETER;
@@ -39,25 +44,47 @@
     return EFI_ALREADY_STARTED;
   }
 
+  //
+  // Detect whether using ipv6 or not, and set it to the private data.
+  //
+  if (UsingIpv6 && Private->Ip6Nic != NULL) {
+    Private->UsingIpv6 = TRUE;
+  } else if (!UsingIpv6 && Private->Ip4Nic != NULL) {
+    Private->UsingIpv6 = FALSE;
+  } else {
+    return EFI_UNSUPPORTED;
+  }
+  
+  //
+  // Init the content of cached DHCP offer list.
+  //
+  ZeroMem (Private->OfferBuffer, sizeof (Private->OfferBuffer));
   if (!Private->UsingIpv6) {
-    //
-    // Init the content of cached DHCP offer list.
-    //
-    ZeroMem (Private->OfferBuffer, sizeof (Private->OfferBuffer));
     for (Index = 0; Index < HTTP_BOOT_OFFER_MAX_NUM; Index++) {
       Private->OfferBuffer[Index].Dhcp4.Packet.Offer.Size = 
HTTP_BOOT_DHCP4_PACKET_MAX_SIZE;
     }
   } else {
-    ASSERT (FALSE);
+    for (Index = 0; Index < HTTP_BOOT_OFFER_MAX_NUM; Index++) {
+      Private->OfferBuffer[Index].Dhcp6.Packet.Offer.Size = 
HTTP_BOOT_DHCP6_PACKET_MAX_SIZE;
+    }
   }
 
+  if (Private->UsingIpv6) {
+    //
+    // Set Ip6 policy to Automatic to start the Ip6 router discovery.
+    //

@@ Diff output truncated at 100000 characters. @@

------------------------------------------------------------------------------
Presto, an open source distributed SQL query engine for big data, initially
developed by Facebook, enables you to easily query your data on Hadoop in a 
more interactive manner. Teradata is also now providing full enterprise
support for Presto. Download a free open source copy now.
http://pubads.g.doubleclick.net/gampad/clk?id=250295911&iu=/4140
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to