VirtualBox

Ignore:
Timestamp:
Apr 14, 2023 3:17:44 PM (22 months ago)
Author:
vboxsync
Message:

Devices/EFI/FirmwareNew: Update to edk2-stable202302 and make it build, bugref:4643

Location:
trunk/src/VBox/Devices/EFI/FirmwareNew
Files:
2 edited

Legend:

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

  • trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c

    r85718 r99404  
    1616//   ALL_DHCP_Relay_Agents_and_Servers address: FF02::1:2
    1717//
    18 EFI_IPv6_ADDRESS   mAllDhcpRelayAndServersAddress = {{0xFF, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2}};
     18EFI_IPv6_ADDRESS  mAllDhcpRelayAndServersAddress = {
     19  { 0xFF, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2 }
     20};
    1921
    2022/**
     
    3133EFI_DHCP6_PACKET_OPTION *
    3234PxeBcParseDhcp6Options (
    33   IN UINT8                       *Buffer,
    34   IN UINT32                      Length,
    35   IN UINT16                      OptTag
     35  IN UINT8   *Buffer,
     36  IN UINT32  Length,
     37  IN UINT16  OptTag
    3638  )
    3739{
    38   EFI_DHCP6_PACKET_OPTION        *Option;
    39   UINT32                         Offset;
    40 
    41   Option  = (EFI_DHCP6_PACKET_OPTION *) Buffer;
    42   Offset  = 0;
     40  EFI_DHCP6_PACKET_OPTION  *Option;
     41  UINT32                   Offset;
     42
     43  Option = (EFI_DHCP6_PACKET_OPTION *)Buffer;
     44  Offset = 0;
    4345
    4446  //
     
    4648  //
    4749  while (Offset < Length) {
    48 
    4950    if (NTOHS (Option->OpCode) == OptTag) {
    50 
    5151      return Option;
    5252    }
    5353
    54     Offset += (NTOHS(Option->OpLen) + 4);
    55     Option  = (EFI_DHCP6_PACKET_OPTION *) (Buffer + Offset);
     54    Offset += (NTOHS (Option->OpLen) + 4);
     55    Option  = (EFI_DHCP6_PACKET_OPTION *)(Buffer + Offset);
    5656  }
    5757
    5858  return NULL;
    5959}
    60 
    6160
    6261/**
     
    7271UINT32
    7372PxeBcBuildDhcp6Options (
    74   IN  PXEBC_PRIVATE_DATA           *Private,
    75   OUT EFI_DHCP6_PACKET_OPTION      **OptList,
    76   IN  UINT8                        *Buffer
     73  IN  PXEBC_PRIVATE_DATA       *Private,
     74  OUT EFI_DHCP6_PACKET_OPTION  **OptList,
     75  IN  UINT8                    *Buffer
    7776  )
    7877{
    79   PXEBC_DHCP6_OPTION_ENTRY         OptEnt;
    80   UINT32                           Index;
    81   UINT16                           Value;
    82 
    83   Index       = 0;
    84   OptList[0]  = (EFI_DHCP6_PACKET_OPTION *) Buffer;
     78  PXEBC_DHCP6_OPTION_ENTRY  OptEnt;
     79  UINT32                    Index;
     80  UINT16                    Value;
     81
     82  Index      = 0;
     83  OptList[0] = (EFI_DHCP6_PACKET_OPTION *)Buffer;
    8584
    8685  //
    8786  // Append client option request option
    8887  //
    89   OptList[Index]->OpCode     = HTONS (DHCP6_OPT_ORO);
    90   OptList[Index]->OpLen      = HTONS (8);
    91   OptEnt.Oro                 = (PXEBC_DHCP6_OPTION_ORO *) OptList[Index]->Data;
    92   OptEnt.Oro->OpCode[0]      = HTONS(DHCP6_OPT_BOOT_FILE_URL);
    93   OptEnt.Oro->OpCode[1]      = HTONS(DHCP6_OPT_BOOT_FILE_PARAM);
    94   OptEnt.Oro->OpCode[2]      = HTONS(DHCP6_OPT_DNS_SERVERS);
    95   OptEnt.Oro->OpCode[3]      = HTONS(DHCP6_OPT_VENDOR_CLASS);
     88  OptList[Index]->OpCode = HTONS (DHCP6_OPT_ORO);
     89  OptList[Index]->OpLen  = HTONS (8);
     90  OptEnt.Oro             = (PXEBC_DHCP6_OPTION_ORO *)OptList[Index]->Data;
     91  OptEnt.Oro->OpCode[0]  = HTONS (DHCP6_OPT_BOOT_FILE_URL);
     92  OptEnt.Oro->OpCode[1]  = HTONS (DHCP6_OPT_BOOT_FILE_PARAM);
     93  OptEnt.Oro->OpCode[2]  = HTONS (DHCP6_OPT_DNS_SERVERS);
     94  OptEnt.Oro->OpCode[3]  = HTONS (DHCP6_OPT_VENDOR_CLASS);
    9695  Index++;
    97   OptList[Index]             = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
     96  OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
    9897
    9998  //
    10099  // Append client network device interface option
    101100  //
    102   OptList[Index]->OpCode     = HTONS (DHCP6_OPT_UNDI);
    103   OptList[Index]->OpLen      = HTONS ((UINT16)3);
    104   OptEnt.Undi                = (PXEBC_DHCP6_OPTION_UNDI *) OptList[Index]->Data;
     101  OptList[Index]->OpCode = HTONS (DHCP6_OPT_UNDI);
     102  OptList[Index]->OpLen  = HTONS ((UINT16)3);
     103  OptEnt.Undi            = (PXEBC_DHCP6_OPTION_UNDI *)OptList[Index]->Data;
    105104
    106105  if (Private->Nii != NULL) {
    107     OptEnt.Undi->Type        = Private->Nii->Type;
    108     OptEnt.Undi->MajorVer    = Private->Nii->MajorVer;
    109     OptEnt.Undi->MinorVer    = Private->Nii->MinorVer;
     106    OptEnt.Undi->Type     = Private->Nii->Type;
     107    OptEnt.Undi->MajorVer = Private->Nii->MajorVer;
     108    OptEnt.Undi->MinorVer = Private->Nii->MinorVer;
    110109  } else {
    111     OptEnt.Undi->Type        = DEFAULT_UNDI_TYPE;
    112     OptEnt.Undi->MajorVer    = DEFAULT_UNDI_MAJOR;
    113     OptEnt.Undi->MinorVer    = DEFAULT_UNDI_MINOR;
     110    OptEnt.Undi->Type     = DEFAULT_UNDI_TYPE;
     111    OptEnt.Undi->MajorVer = DEFAULT_UNDI_MAJOR;
     112    OptEnt.Undi->MinorVer = DEFAULT_UNDI_MINOR;
    114113  }
    115114
    116115  Index++;
    117   OptList[Index]             = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
     116  OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
    118117
    119118  //
    120119  // Append client system architecture option
    121120  //
    122   OptList[Index]->OpCode     = HTONS (DHCP6_OPT_ARCH);
    123   OptList[Index]->OpLen      = HTONS ((UINT16) sizeof (PXEBC_DHCP6_OPTION_ARCH));
    124   OptEnt.Arch                = (PXEBC_DHCP6_OPTION_ARCH *) OptList[Index]->Data;
    125   Value                      = HTONS (EFI_PXE_CLIENT_SYSTEM_ARCHITECTURE);
     121  OptList[Index]->OpCode = HTONS (DHCP6_OPT_ARCH);
     122  OptList[Index]->OpLen  = HTONS ((UINT16)sizeof (PXEBC_DHCP6_OPTION_ARCH));
     123  OptEnt.Arch            = (PXEBC_DHCP6_OPTION_ARCH *)OptList[Index]->Data;
     124  Value                  = HTONS (EFI_PXE_CLIENT_SYSTEM_ARCHITECTURE);
    126125  CopyMem (&OptEnt.Arch->Type, &Value, sizeof (UINT16));
    127126  Index++;
    128   OptList[Index]             = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
     127  OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
    129128
    130129  //
     
    132131  //
    133132  OptList[Index]->OpCode       = HTONS (DHCP6_OPT_VENDOR_CLASS);
    134   OptList[Index]->OpLen        = HTONS ((UINT16) sizeof (PXEBC_DHCP6_OPTION_VENDOR_CLASS));
    135   OptEnt.VendorClass           = (PXEBC_DHCP6_OPTION_VENDOR_CLASS *) OptList[Index]->Data;
     133  OptList[Index]->OpLen        = HTONS ((UINT16)sizeof (PXEBC_DHCP6_OPTION_VENDOR_CLASS));
     134  OptEnt.VendorClass           = (PXEBC_DHCP6_OPTION_VENDOR_CLASS *)OptList[Index]->Data;
    136135  OptEnt.VendorClass->Vendor   = HTONL (PXEBC_DHCP6_ENTERPRISE_NUM);
    137   OptEnt.VendorClass->ClassLen = HTONS ((UINT16) sizeof (PXEBC_CLASS_ID));
     136  OptEnt.VendorClass->ClassLen = HTONS ((UINT16)sizeof (PXEBC_CLASS_ID));
    138137  CopyMem (
    139138    &OptEnt.VendorClass->ClassId,
     
    170169}
    171170
    172 
    173171/**
    174172  Cache the DHCPv6 packet.
     
    183181EFI_STATUS
    184182PxeBcCacheDhcp6Packet (
    185   IN EFI_DHCP6_PACKET          *Dst,
    186   IN EFI_DHCP6_PACKET          *Src
     183  IN EFI_DHCP6_PACKET  *Dst,
     184  IN EFI_DHCP6_PACKET  *Src
    187185  )
    188186{
     
    212210EFI_STATUS
    213211PxeBcDns6 (
    214   IN PXEBC_PRIVATE_DATA           *Private,
    215   IN     CHAR16                   *HostName,
    216      OUT EFI_IPv6_ADDRESS         *IpAddress
     212  IN PXEBC_PRIVATE_DATA  *Private,
     213  IN     CHAR16          *HostName,
     214  OUT EFI_IPv6_ADDRESS   *IpAddress
    217215  )
    218216{
    219   EFI_STATUS                      Status;
    220   EFI_DNS6_PROTOCOL               *Dns6;
    221   EFI_DNS6_CONFIG_DATA            Dns6ConfigData;
    222   EFI_DNS6_COMPLETION_TOKEN       Token;
    223   EFI_HANDLE                      Dns6Handle;
    224   EFI_IPv6_ADDRESS                *DnsServerList;
    225   BOOLEAN                         IsDone;
    226 
    227   Dns6                = NULL;
    228   Dns6Handle          = NULL;
    229   DnsServerList       = Private->DnsServer;
     217  EFI_STATUS                 Status;
     218  EFI_DNS6_PROTOCOL          *Dns6;
     219  EFI_DNS6_CONFIG_DATA       Dns6ConfigData;
     220  EFI_DNS6_COMPLETION_TOKEN  Token;
     221  EFI_HANDLE                 Dns6Handle;
     222  EFI_IPv6_ADDRESS           *DnsServerList;
     223  BOOLEAN                    IsDone;
     224
     225  Dns6          = NULL;
     226  Dns6Handle    = NULL;
     227  DnsServerList = Private->DnsServer;
    230228  ZeroMem (&Token, sizeof (EFI_DNS6_COMPLETION_TOKEN));
    231229
     
    246244                  Dns6Handle,
    247245                  &gEfiDns6ProtocolGuid,
    248                   (VOID **) &Dns6,
     246                  (VOID **)&Dns6,
    249247                  Private->Image,
    250248                  Private->Controller,
     
    309307      goto Exit;
    310308    }
    311     if (Token.RspData.H2AData->IpCount == 0 || Token.RspData.H2AData->IpList == NULL) {
     309
     310    if ((Token.RspData.H2AData->IpCount == 0) || (Token.RspData.H2AData->IpList == NULL)) {
    312311      Status = EFI_DEVICE_ERROR;
    313312      goto Exit;
    314313    }
     314
    315315    //
    316316    // We just return the first IPv6 address from DNS protocol.
     
    326326    gBS->CloseEvent (Token.Event);
    327327  }
     328
    328329  if (Token.RspData.H2AData != NULL) {
    329330    if (Token.RspData.H2AData->IpList != NULL) {
    330331      FreePool (Token.RspData.H2AData->IpList);
    331332    }
     333
    332334    FreePool (Token.RspData.H2AData);
    333335  }
     
    376378EFI_STATUS
    377379PxeBcExtractBootFileUrl (
    378   IN PXEBC_PRIVATE_DATA      *Private,
    379      OUT UINT8               **FileName,
    380   IN OUT EFI_IPv6_ADDRESS    *SrvAddr,
    381   IN     CHAR8               *BootFile,
    382   IN     UINT16              Length
     380  IN PXEBC_PRIVATE_DATA    *Private,
     381  OUT UINT8                **FileName,
     382  IN OUT EFI_IPv6_ADDRESS  *SrvAddr,
     383  IN     CHAR8             *BootFile,
     384  IN     UINT16            Length
    383385  )
    384386{
    385   UINT16                     PrefixLen;
    386   CHAR8                      *BootFileNamePtr;
    387   CHAR8                      *BootFileName;
    388   UINT16                     BootFileNameLen;
    389   CHAR8                      *TmpStr;
    390   CHAR8                      TmpChar;
    391   CHAR8                      *ServerAddressOption;
    392   CHAR8                      *ServerAddress;
    393   CHAR8                      *ModeStr;
    394   CHAR16                     *HostName;
    395   BOOLEAN                    IpExpressedUrl;
    396   UINTN                      Len;
    397   EFI_STATUS                 Status;
     387  UINT16      PrefixLen;
     388  CHAR8       *BootFileNamePtr;
     389  CHAR8       *BootFileName;
     390  UINT16      BootFileNameLen;
     391  CHAR8       *TmpStr;
     392  CHAR8       TmpChar;
     393  CHAR8       *ServerAddressOption;
     394  CHAR8       *ServerAddress;
     395  CHAR8       *ModeStr;
     396  CHAR16      *HostName;
     397  BOOLEAN     IpExpressedUrl;
     398  UINTN       Len;
     399  EFI_STATUS  Status;
    398400
    399401  IpExpressedUrl = TRUE;
     
    418420  // SERVER_ADDRESS is the ASCII encoding of an IPV6 address.
    419421  //
    420   PrefixLen = (UINT16) AsciiStrLen (PXEBC_DHCP6_BOOT_FILE_URL_PREFIX);
    421 
    422   if (Length <= PrefixLen ||
    423       CompareMem (BootFile, PXEBC_DHCP6_BOOT_FILE_URL_PREFIX, PrefixLen) != 0) {
     422  PrefixLen = (UINT16)AsciiStrLen (PXEBC_DHCP6_BOOT_FILE_URL_PREFIX);
     423
     424  if ((Length <= PrefixLen) ||
     425      (CompareMem (BootFile, PXEBC_DHCP6_BOOT_FILE_URL_PREFIX, PrefixLen) != 0))
     426  {
    424427    return EFI_NOT_FOUND;
    425428  }
    426429
    427430  BootFile = BootFile + PrefixLen;
    428   Length   = (UINT16) (Length - PrefixLen);
    429 
    430   TmpStr = (CHAR8 *) AllocateZeroPool (Length + 1);
     431  Length   = (UINT16)(Length - PrefixLen);
     432
     433  TmpStr = (CHAR8 *)AllocateZeroPool (Length + 1);
    431434  if (TmpStr == NULL) {
    432435    return EFI_OUT_OF_RESOURCES;
     
    441444  ServerAddressOption = TmpStr;
    442445  if (*ServerAddressOption == PXEBC_ADDR_START_DELIMITER) {
    443     ServerAddressOption ++;
     446    ServerAddressOption++;
    444447    ServerAddress = ServerAddressOption;
    445448    while (*ServerAddress != '\0' && *ServerAddress != PXEBC_ADDR_END_DELIMITER) {
     
    462465      return Status;
    463466    }
    464 
    465467  } else {
    466468    IpExpressedUrl = FALSE;
    467     ServerAddress = ServerAddressOption;
     469    ServerAddress  = ServerAddressOption;
    468470    while (*ServerAddress != '\0' && *ServerAddress != PXEBC_TFTP_URL_SEPARATOR) {
    469471      ServerAddress++;
     
    474476      return EFI_INVALID_PARAMETER;
    475477    }
     478
    476479    *ServerAddress = '\0';
    477480
    478     Len = AsciiStrSize (ServerAddressOption);
     481    Len      = AsciiStrSize (ServerAddressOption);
    479482    HostName = AllocateZeroPool (Len * sizeof (CHAR16));
    480483    if (HostName == NULL) {
     
    482485      return EFI_OUT_OF_RESOURCES;
    483486    }
     487
    484488    AsciiStrToUnicodeStrS (
    485489      ServerAddressOption,
     
    491495    // Perform DNS resolution.
    492496    //
    493     Status = PxeBcDns6 (Private,HostName, SrvAddr);
     497    Status = PxeBcDns6 (Private, HostName, SrvAddr);
    494498    if (EFI_ERROR (Status)) {
    495499      FreePool (TmpStr);
     
    501505  // Get the part of BOOTFILE_NAME string.
    502506  //
    503   BootFileNamePtr = (CHAR8*)((UINTN)ServerAddress + 1);
     507  BootFileNamePtr = (CHAR8 *)((UINTN)ServerAddress + 1);
    504508  if (IpExpressedUrl) {
    505509    if (*BootFileNamePtr != PXEBC_TFTP_URL_SEPARATOR) {
     
    507511      return EFI_INVALID_PARAMETER;
    508512    }
     513
    509514    ++BootFileNamePtr;
    510515  }
    511516
    512   BootFileNameLen = (UINT16)(Length - (UINT16) ((UINTN)BootFileNamePtr - (UINTN)TmpStr) + 1);
    513   if (BootFileNameLen != 0 || FileName != NULL) {
     517  BootFileNameLen = (UINT16)(Length - (UINT16)((UINTN)BootFileNamePtr - (UINTN)TmpStr) + 1);
     518  if ((BootFileNameLen != 0) || (FileName != NULL)) {
    514519    //
    515520    // Remove trailing mode=octet if present and ignore.  All other modes are
     
    517522    //
    518523    ModeStr = AsciiStrStr (BootFileNamePtr, ";mode=octet");
    519     if (ModeStr != NULL && *(ModeStr + AsciiStrLen (";mode=octet")) == '\0') {
     524    if ((ModeStr != NULL) && (*(ModeStr + AsciiStrLen (";mode=octet")) == '\0')) {
    520525      *ModeStr = '\0';
    521526    } else if (AsciiStrStr (BootFileNamePtr, ";mode=") != NULL) {
     
    527532    // Extract boot file name from URL.
    528533    //
    529     BootFileName = (CHAR8 *) AllocateZeroPool (BootFileNameLen);
     534    BootFileName = (CHAR8 *)AllocateZeroPool (BootFileNameLen);
    530535    if (BootFileName == NULL) {
    531536      FreePool (TmpStr);
    532537      return EFI_OUT_OF_RESOURCES;
    533538    }
    534     *FileName = (UINT8*) BootFileName;
     539
     540    *FileName = (UINT8 *)BootFileName;
    535541
    536542    //
     
    539545    while (*BootFileNamePtr != '\0') {
    540546      if (*BootFileNamePtr == '%') {
    541         TmpChar = *(BootFileNamePtr+ 3);
     547        TmpChar               = *(BootFileNamePtr+ 3);
    542548        *(BootFileNamePtr+ 3) = '\0';
    543         *BootFileName = (UINT8) AsciiStrHexToUintn ((CHAR8*)(BootFileNamePtr + 1));
     549        *BootFileName         = (UINT8)AsciiStrHexToUintn ((CHAR8 *)(BootFileNamePtr + 1));
    544550        BootFileName++;
    545551        *(BootFileNamePtr+ 3) = TmpChar;
    546         BootFileNamePtr += 3;
     552        BootFileNamePtr      += 3;
    547553      } else {
    548554        *BootFileName = *BootFileNamePtr;
     
    551557      }
    552558    }
     559
    553560    *BootFileName = '\0';
    554561  }
     
    558565  return EFI_SUCCESS;
    559566}
    560 
    561567
    562568/**
     
    572578EFI_STATUS
    573579PxeBcExtractBootFileParam (
    574   IN  CHAR8                  *BootFilePara,
    575   OUT UINT16                 *BootFileSize
     580  IN  CHAR8   *BootFilePara,
     581  OUT UINT16  *BootFileSize
    576582  )
    577583{
    578   UINT16                     Length;
    579   UINT8                      Index;
    580   UINT8                      Digit;
    581   UINT32                     Size;
     584  UINT16  Length;
     585  UINT8   Index;
     586  UINT8   Digit;
     587  UINT32  Size;
    582588
    583589  CopyMem (&Length, BootFilePara, sizeof (UINT16));
     
    587593  // The BootFile Size should be 1~5 byte ASCII strings
    588594  //
    589   if (Length < 1 || Length > 5) {
     595  if ((Length < 1) || (Length > 5)) {
    590596    return EFI_NOT_FOUND;
    591597  }
     
    609615  }
    610616
    611   *BootFileSize = (UINT16) Size;
     617  *BootFileSize = (UINT16)Size;
    612618  return EFI_SUCCESS;
    613619}
    614 
    615620
    616621/**
     
    628633  )
    629634{
    630   EFI_DHCP6_PACKET             *Offer;
    631   EFI_DHCP6_PACKET_OPTION      **Options;
    632   EFI_DHCP6_PACKET_OPTION      *Option;
    633   PXEBC_OFFER_TYPE             OfferType;
    634   BOOLEAN                      IsProxyOffer;
    635   BOOLEAN                      IsPxeOffer;
    636   UINT32                       Offset;
    637   UINT32                       Length;
    638   UINT32                       EnterpriseNum;
     635  EFI_DHCP6_PACKET         *Offer;
     636  EFI_DHCP6_PACKET_OPTION  **Options;
     637  EFI_DHCP6_PACKET_OPTION  *Option;
     638  PXEBC_OFFER_TYPE         OfferType;
     639  BOOLEAN                  IsProxyOffer;
     640  BOOLEAN                  IsPxeOffer;
     641  UINT32                   Offset;
     642  UINT32                   Length;
     643  UINT32                   EnterpriseNum;
    639644
    640645  IsProxyOffer = TRUE;
     
    645650  ZeroMem (Cache6->OptList, sizeof (Cache6->OptList));
    646651
    647   Option  = (EFI_DHCP6_PACKET_OPTION *) (Offer->Dhcp6.Option);
    648   Offset  = 0;
    649   Length  = GET_DHCP6_OPTION_SIZE (Offer);
     652  Option = (EFI_DHCP6_PACKET_OPTION *)(Offer->Dhcp6.Option);
     653  Offset = 0;
     654  Length = GET_DHCP6_OPTION_SIZE (Offer);
    650655
    651656  //
     
    653658  //
    654659  while (Offset < Length) {
    655 
    656660    if (NTOHS (Option->OpCode) == DHCP6_OPT_IA_NA) {
    657661      Options[PXEBC_DHCP6_IDX_IA_NA] = Option;
     
    670674
    671675    Offset += (NTOHS (Option->OpLen) + 4);
    672     Option  = (EFI_DHCP6_PACKET_OPTION *) (Offer->Dhcp6.Option + Offset);
     676    Option  = (EFI_DHCP6_PACKET_OPTION *)(Offer->Dhcp6.Option + Offset);
    673677  }
    674678
     
    684688               DHCP6_OPT_STATUS_CODE
    685689               );
    686     if ((Option != NULL && Option->Data[0] == 0) || (Option == NULL)) {
     690    if (((Option != NULL) && (Option->Data[0] == 0)) || (Option == NULL)) {
    687691      IsProxyOffer = FALSE;
    688692    }
     
    693697  //
    694698  Option        = Options[PXEBC_DHCP6_IDX_VENDOR_CLASS];
    695   EnterpriseNum = HTONL(PXEBC_DHCP6_ENTERPRISE_NUM);
    696 
    697   if (Option != NULL &&
    698       NTOHS(Option->OpLen) >= 13 &&
    699       CompareMem (Option->Data, &EnterpriseNum, sizeof (UINT32)) == 0 &&
    700       CompareMem (&Option->Data[6], DEFAULT_CLASS_ID_DATA, 9) == 0) {
     699  EnterpriseNum = HTONL (PXEBC_DHCP6_ENTERPRISE_NUM);
     700
     701  if ((Option != NULL) &&
     702      (NTOHS (Option->OpLen) >= 13) &&
     703      (CompareMem (Option->Data, &EnterpriseNum, sizeof (UINT32)) == 0) &&
     704      (CompareMem (&Option->Data[6], DEFAULT_CLASS_ID_DATA, 9) == 0))
     705  {
    701706    IsPxeOffer = TRUE;
    702707  }
     
    721726  return EFI_SUCCESS;
    722727}
    723 
    724728
    725729/**
     
    736740EFI_STATUS
    737741PxeBcCopyDhcp6Ack (
    738   IN PXEBC_PRIVATE_DATA   *Private,
    739   IN EFI_DHCP6_PACKET     *Ack,
    740   IN BOOLEAN              Verified
     742  IN PXEBC_PRIVATE_DATA  *Private,
     743  IN EFI_DHCP6_PACKET    *Ack,
     744  IN BOOLEAN             Verified
    741745  )
    742746{
     
    763767}
    764768
    765 
    766769/**
    767770  Cache the DHCPv6 proxy offer packet according to the received order.
     
    776779EFI_STATUS
    777780PxeBcCopyDhcp6Proxy (
    778   IN PXEBC_PRIVATE_DATA     *Private,
    779   IN UINT32                 OfferIndex
     781  IN PXEBC_PRIVATE_DATA  *Private,
     782  IN UINT32              OfferIndex
    780783  )
    781784{
    782   EFI_PXE_BASE_CODE_MODE    *Mode;
    783   EFI_DHCP6_PACKET          *Offer;
     785  EFI_PXE_BASE_CODE_MODE  *Mode;
     786  EFI_DHCP6_PACKET        *Offer;
    784787  EFI_STATUS              Status;
    785788
     
    794797  //
    795798  Status = PxeBcCacheDhcp6Packet (&Private->ProxyOffer.Dhcp6.Packet.Offer, Offer);
    796   if (EFI_ERROR(Status)) {
     799  if (EFI_ERROR (Status)) {
    797800    return Status;
    798801  }
     802
    799803  PxeBcParseDhcp6Packet (&Private->ProxyOffer.Dhcp6);
    800804
     
    821825UINT8 *
    822826PxeBcDhcp6SeekOption (
    823   IN UINT8           *Buf,
    824   IN UINT32          SeekLen,
    825   IN UINT16          OptType
     827  IN UINT8   *Buf,
     828  IN UINT32  SeekLen,
     829  IN UINT16  OptType
    826830  )
    827831{
    828   UINT8              *Cursor;
    829   UINT8              *Option;
    830   UINT16             DataLen;
    831   UINT16             OpCode;
     832  UINT8   *Cursor;
     833  UINT8   *Option;
     834  UINT16  DataLen;
     835  UINT16  OpCode;
    832836
    833837  Option = NULL;
     
    835839
    836840  while (Cursor < Buf + SeekLen) {
    837     OpCode = ReadUnaligned16 ((UINT16 *) Cursor);
     841    OpCode = ReadUnaligned16 ((UINT16 *)Cursor);
    838842    if (OpCode == HTONS (OptType)) {
    839843      Option = Cursor;
    840844      break;
    841845    }
    842     DataLen = NTOHS (ReadUnaligned16 ((UINT16 *) (Cursor + 2)));
     846
     847    DataLen = NTOHS (ReadUnaligned16 ((UINT16 *)(Cursor + 2)));
    843848    Cursor += (DataLen + 4);
    844849  }
     
    846851  return Option;
    847852}
    848 
    849853
    850854/**
     
    862866EFI_STATUS
    863867PxeBcRequestBootService (
    864   IN  PXEBC_PRIVATE_DATA              *Private,
    865   IN  UINT32                          Index
     868  IN  PXEBC_PRIVATE_DATA  *Private,
     869  IN  UINT32              Index
    866870  )
    867871{
    868   EFI_PXE_BASE_CODE_UDP_PORT          SrcPort;
    869   EFI_PXE_BASE_CODE_UDP_PORT          DestPort;
    870   EFI_PXE_BASE_CODE_PROTOCOL          *PxeBc;
    871   EFI_PXE_BASE_CODE_DHCPV6_PACKET     *Discover;
    872   UINTN                               DiscoverLen;
    873   EFI_DHCP6_PACKET                    *Request;
    874   UINTN                               RequestLen;
    875   EFI_DHCP6_PACKET                    *Reply;
    876   UINT8                               *RequestOpt;
    877   UINT8                               *DiscoverOpt;
    878   UINTN                               ReadSize;
    879   UINT16                              OpFlags;
    880   UINT16                              OpCode;
    881   UINT16                              OpLen;
    882   EFI_STATUS                          Status;
    883   EFI_DHCP6_PACKET                    *IndexOffer;
    884   UINT8                               *Option;
    885 
    886   PxeBc       = &Private->PxeBc;
    887   Request     = Private->Dhcp6Request;
    888   IndexOffer  = &Private->OfferBuffer[Index].Dhcp6.Packet.Offer;
    889   SrcPort     = PXEBC_BS_DISCOVER_PORT;
    890   DestPort    = PXEBC_BS_DISCOVER_PORT;
    891   OpFlags     = 0;
     872  EFI_PXE_BASE_CODE_UDP_PORT       SrcPort;
     873  EFI_PXE_BASE_CODE_UDP_PORT       DestPort;
     874  EFI_PXE_BASE_CODE_PROTOCOL       *PxeBc;
     875  EFI_PXE_BASE_CODE_DHCPV6_PACKET  *Discover;
     876  UINTN                            DiscoverLen;
     877  EFI_DHCP6_PACKET                 *Request;
     878  UINTN                            RequestLen;
     879  EFI_DHCP6_PACKET                 *Reply;
     880  UINT8                            *RequestOpt;
     881  UINT8                            *DiscoverOpt;
     882  UINTN                            ReadSize;
     883  UINT16                           OpFlags;
     884  UINT16                           OpCode;
     885  UINT16                           OpLen;
     886  EFI_STATUS                       Status;
     887  EFI_DHCP6_PACKET                 *IndexOffer;
     888  UINT8                            *Option;
     889
     890  PxeBc      = &Private->PxeBc;
     891  Request    = Private->Dhcp6Request;
     892  IndexOffer = &Private->OfferBuffer[Index].Dhcp6.Packet.Offer;
     893  SrcPort    = PXEBC_BS_DISCOVER_PORT;
     894  DestPort   = PXEBC_BS_DISCOVER_PORT;
     895  OpFlags    = 0;
    892896
    893897  if (Request == NULL) {
     
    926930    // Add Server ID Option.
    927931    //
    928     OpLen = NTOHS (((EFI_DHCP6_PACKET_OPTION *) Option)->OpLen);
     932    OpLen = NTOHS (((EFI_DHCP6_PACKET_OPTION *)Option)->OpLen);
    929933    CopyMem (DiscoverOpt, Option, OpLen + 4);
    930934    DiscoverOpt += (OpLen + 4);
     
    933937
    934938  while (RequestLen < Request->Length) {
    935     OpCode = NTOHS (((EFI_DHCP6_PACKET_OPTION *) RequestOpt)->OpCode);
    936     OpLen  = NTOHS (((EFI_DHCP6_PACKET_OPTION *) RequestOpt)->OpLen);
    937     if (OpCode != EFI_DHCP6_IA_TYPE_NA &&
    938         OpCode != EFI_DHCP6_IA_TYPE_TA &&
    939         OpCode != DHCP6_OPT_SERVER_ID
    940         ) {
     939    OpCode = NTOHS (((EFI_DHCP6_PACKET_OPTION *)RequestOpt)->OpCode);
     940    OpLen  = NTOHS (((EFI_DHCP6_PACKET_OPTION *)RequestOpt)->OpLen);
     941    if ((OpCode != EFI_DHCP6_IA_TYPE_NA) &&
     942        (OpCode != EFI_DHCP6_IA_TYPE_TA) &&
     943        (OpCode != DHCP6_OPT_SERVER_ID)
     944        )
     945    {
    941946      //
    942947      // Copy all the options except IA option and Server ID
     
    946951      DiscoverLen += (OpLen + 4);
    947952    }
     953
    948954    RequestOpt += (OpLen + 4);
    949955    RequestLen += (OpLen + 4);
     
    960966  if (Option != NULL) {
    961967    CalcElapsedTime (Private);
    962     WriteUnaligned16 ((UINT16*)(Option + 4), HTONS((UINT16) Private->ElapsedTime));
     968    WriteUnaligned16 ((UINT16 *)(Option + 4), HTONS ((UINT16)Private->ElapsedTime));
    963969  }
    964970
     
    974980                    NULL,
    975981                    &DiscoverLen,
    976                     (VOID *) Discover
     982                    (VOID *)Discover
    977983                    );
    978984
     
    985991  // Especially for PXE discover packet, store it into mode data here.
    986992  //
    987   Reply = &Private->ProxyOffer.Dhcp6.Packet.Offer;
    988   ReadSize = (UINTN) Reply->Size;
     993  Reply    = &Private->ProxyOffer.Dhcp6.Packet.Offer;
     994  ReadSize = (UINTN)Reply->Size;
    989995
    990996  //
     
    10061012                    NULL,
    10071013                    &ReadSize,
    1008                     (VOID *) &Reply->Dhcp6
     1014                    (VOID *)&Reply->Dhcp6
    10091015                    );
    10101016  //
     
    10201026  // Update length
    10211027  //
    1022   Reply->Length = (UINT32) ReadSize;
     1028  Reply->Length = (UINT32)ReadSize;
    10231029
    10241030  return EFI_SUCCESS;
     
    10311037  return Status;
    10321038}
    1033 
    10341039
    10351040/**
     
    10551060
    10561061  ASSERT (Index < PXEBC_OFFER_MAX_NUM);
    1057   ASSERT (Private->OfferBuffer[Index].Dhcp6.OfferType == PxeOfferTypeDhcpBinl ||
    1058           Private->OfferBuffer[Index].Dhcp6.OfferType == PxeOfferTypeProxyBinl);
     1062  ASSERT (
     1063    Private->OfferBuffer[Index].Dhcp6.OfferType == PxeOfferTypeDhcpBinl ||
     1064    Private->OfferBuffer[Index].Dhcp6.OfferType == PxeOfferTypeProxyBinl
     1065    );
    10591066
    10601067  Mode                  = Private->PxeBc.Mode;
     
    10791086               &Private->BootFileName,
    10801087               &Private->ServerIp.v6,
    1081                (CHAR8 *) (Offer->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL]->Data),
     1088               (CHAR8 *)(Offer->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL]->Data),
    10821089               NTOHS (Offer->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL]->OpLen)
    10831090               );
     
    11021109  }
    11031110
    1104   if (Cache6->OfferType != PxeOfferTypeProxyPxe10 &&
    1105       Cache6->OfferType != PxeOfferTypeProxyWfm11a &&
    1106       Cache6->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL] == NULL) {
     1111  if ((Cache6->OfferType != PxeOfferTypeProxyPxe10) &&
     1112      (Cache6->OfferType != PxeOfferTypeProxyWfm11a) &&
     1113      (Cache6->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL] == NULL))
     1114  {
    11071115    //
    11081116    // This BINL ack doesn't have discovery option set or multicast option set
     
    11221130}
    11231131
    1124 
    11251132/**
    11261133  Cache all the received DHCPv6 offers, and set OfferIndex and OfferCount.
     
    11341141EFI_STATUS
    11351142PxeBcCacheDhcp6Offer (
    1136   IN PXEBC_PRIVATE_DATA     *Private,
    1137   IN EFI_DHCP6_PACKET       *RcvdOffer
     1143  IN PXEBC_PRIVATE_DATA  *Private,
     1144  IN EFI_DHCP6_PACKET    *RcvdOffer
    11381145  )
    11391146{
     
    11801187      Private->OfferIndex[OfferType][Private->OfferCount[OfferType]] = Private->OfferNum;
    11811188      Private->OfferCount[OfferType]++;
    1182     } else if ((OfferType == PxeOfferTypeProxyPxe10 || OfferType == PxeOfferTypeProxyWfm11a) &&
    1183                  Private->OfferCount[OfferType] < 1) {
     1189    } else if (((OfferType == PxeOfferTypeProxyPxe10) || (OfferType == PxeOfferTypeProxyWfm11a)) &&
     1190               (Private->OfferCount[OfferType] < 1))
     1191    {
    11841192      //
    11851193      // Only cache the first PXE10/WFM11a offer, and discard the others.
     
    12031211}
    12041212
    1205 
    12061213/**
    12071214  Select an DHCPv6 offer, and record SelectIndex and SelectProxyType.
     
    12121219VOID
    12131220PxeBcSelectDhcp6Offer (
    1214   IN PXEBC_PRIVATE_DATA     *Private
     1221  IN PXEBC_PRIVATE_DATA  *Private
    12151222  )
    12161223{
    1217   UINT32                Index;
    1218   UINT32                OfferIndex;
    1219   PXEBC_OFFER_TYPE      OfferType;
     1224  UINT32            Index;
     1225  UINT32            OfferIndex;
     1226  PXEBC_OFFER_TYPE  OfferType;
    12201227
    12211228  Private->SelectIndex = 0;
     
    12301237      //
    12311238      Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpPxe10][0] + 1;
    1232 
    12331239    } else if (Private->OfferCount[PxeOfferTypeDhcpWfm11a] > 0) {
    12341240      //
     
    12361242      //
    12371243      Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpWfm11a][0] + 1;
    1238 
    1239     } else if (Private->OfferCount[PxeOfferTypeDhcpOnly] > 0 &&
    1240                Private->OfferCount[PxeOfferTypeProxyPxe10] > 0) {
     1244    } else if ((Private->OfferCount[PxeOfferTypeDhcpOnly] > 0) &&
     1245               (Private->OfferCount[PxeOfferTypeProxyPxe10] > 0))
     1246    {
    12411247      //
    12421248      // 3. DhcpOnly offer and ProxyPxe10 offer.
     
    12441250      Private->SelectIndex     = Private->OfferIndex[PxeOfferTypeDhcpOnly][0] + 1;
    12451251      Private->SelectProxyType = PxeOfferTypeProxyPxe10;
    1246 
    1247     } else if (Private->OfferCount[PxeOfferTypeDhcpOnly] > 0 &&
    1248                Private->OfferCount[PxeOfferTypeProxyWfm11a] > 0) {
     1252    } else if ((Private->OfferCount[PxeOfferTypeDhcpOnly] > 0) &&
     1253               (Private->OfferCount[PxeOfferTypeProxyWfm11a] > 0))
     1254    {
    12491255      //
    12501256      // 4. DhcpOnly offer and ProxyWfm11a offer.
     
    12521258      Private->SelectIndex     = Private->OfferIndex[PxeOfferTypeDhcpOnly][0] + 1;
    12531259      Private->SelectProxyType = PxeOfferTypeProxyWfm11a;
    1254 
    12551260    } else if (Private->OfferCount[PxeOfferTypeDhcpBinl] > 0) {
    12561261      //
     
    12581263      //
    12591264      Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpBinl][0] + 1;
    1260 
    1261     } else if (Private->OfferCount[PxeOfferTypeDhcpOnly] > 0 &&
    1262                Private->OfferCount[PxeOfferTypeProxyBinl] > 0) {
     1265    } else if ((Private->OfferCount[PxeOfferTypeDhcpOnly] > 0) &&
     1266               (Private->OfferCount[PxeOfferTypeProxyBinl] > 0))
     1267    {
    12631268      //
    12641269      // 6. DhcpOnly offer and ProxyBinl offer.
     
    12661271      Private->SelectIndex     = Private->OfferIndex[PxeOfferTypeDhcpOnly][0] + 1;
    12671272      Private->SelectProxyType = PxeOfferTypeProxyBinl;
    1268 
    12691273    } else {
    12701274      //
     
    12841288    //
    12851289    for (Index = 0; Index < Private->OfferNum; Index++) {
    1286 
    12871290      OfferType = Private->OfferBuffer[Index].Dhcp6.OfferType;
    12881291
     
    12951298
    12961299      if (!Private->IsProxyRecved &&
    1297           OfferType == PxeOfferTypeDhcpOnly &&
    1298           Private->OfferBuffer[Index].Dhcp6.OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL] == NULL) {
     1300          (OfferType == PxeOfferTypeDhcpOnly) &&
     1301          (Private->OfferBuffer[Index].Dhcp6.OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL] == NULL))
     1302      {
    12991303        //
    13001304        // Skip if DhcpOnly offer without any other proxy offers or bootfilename.
     
    13091313}
    13101314
    1311 
    13121315/**
    13131316  Handle the DHCPv6 offer packet.
     
    13231326EFI_STATUS
    13241327PxeBcHandleDhcp6Offer (
    1325   IN PXEBC_PRIVATE_DATA            *Private
     1328  IN PXEBC_PRIVATE_DATA  *Private
    13261329  )
    13271330{
    1328   PXEBC_DHCP6_PACKET_CACHE         *Cache6;
    1329   EFI_STATUS                       Status;
    1330   PXEBC_OFFER_TYPE                 OfferType;
    1331   UINT32                           ProxyIndex;
    1332   UINT32                           SelectIndex;
    1333   UINT32                           Index;
     1331  PXEBC_DHCP6_PACKET_CACHE  *Cache6;
     1332  EFI_STATUS                Status;
     1333  PXEBC_OFFER_TYPE          OfferType;
     1334  UINT32                    ProxyIndex;
     1335  UINT32                    SelectIndex;
     1336  UINT32                    Index;
    13341337
    13351338  ASSERT (Private->SelectIndex > 0);
    1336   SelectIndex = (UINT32) (Private->SelectIndex - 1);
     1339  SelectIndex = (UINT32)(Private->SelectIndex - 1);
    13371340  ASSERT (SelectIndex < PXEBC_OFFER_MAX_NUM);
    1338   Cache6      = &Private->OfferBuffer[SelectIndex].Dhcp6;
    1339   Status      = EFI_SUCCESS;
     1341  Cache6 = &Private->OfferBuffer[SelectIndex].Dhcp6;
     1342  Status = EFI_SUCCESS;
    13401343
    13411344  //
     
    13471350      return EFI_OUT_OF_RESOURCES;
    13481351    }
     1352
    13491353    CopyMem (Private->DnsServer, Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER]->Data, sizeof (EFI_IPv6_ADDRESS));
    13501354  }
     
    13581362    }
    13591363  } else if (Cache6->OfferType == PxeOfferTypeDhcpOnly) {
    1360 
    13611364    if (Private->IsProxyRecved) {
    13621365      //
     
    13761379          //
    13771380          for (Index = 0; Index < Private->OfferCount[Private->SelectProxyType]; Index++) {
    1378 
    13791381            ProxyIndex = Private->OfferIndex[Private->SelectProxyType][Index];
    13801382            if (!EFI_ERROR (PxeBcRetryDhcp6Binl (Private, ProxyIndex))) {
     
    13821384            }
    13831385          }
     1386
    13841387          if (Index == Private->OfferCount[Private->SelectProxyType]) {
    13851388            Status = EFI_NO_RESPONSE;
     
    13981401
    13991402        for (Index = 0; Index < Private->OfferNum; Index++) {
    1400 
    14011403          OfferType = Private->OfferBuffer[Index].Dhcp6.OfferType;
    14021404
     
    14241426      }
    14251427
    1426       if (!EFI_ERROR (Status) && Private->SelectProxyType != PxeOfferTypeProxyBinl) {
     1428      if (!EFI_ERROR (Status) && (Private->SelectProxyType != PxeOfferTypeProxyBinl)) {
    14271429        //
    14281430        // Success to try to request by a ProxyPxe10 or ProxyWfm11a offer, copy and parse it.
     
    14421444    // All PXE boot information is ready by now.
    14431445    //
    1444     Status = PxeBcCopyDhcp6Ack (Private, &Private->DhcpAck.Dhcp6.Packet.Ack, TRUE);
     1446    Status                                 = PxeBcCopyDhcp6Ack (Private, &Private->DhcpAck.Dhcp6.Packet.Ack, TRUE);
    14451447    Private->PxeBc.Mode->DhcpDiscoverValid = TRUE;
    14461448  }
     
    14481450  return Status;
    14491451}
    1450 
    14511452
    14521453/**
     
    14581459VOID
    14591460PxeBcUnregisterIp6Address (
    1460   IN PXEBC_PRIVATE_DATA           *Private
     1461  IN PXEBC_PRIVATE_DATA  *Private
    14611462  )
    14621463{
     
    14861487EFI_STATUS
    14871488PxeBcCheckRouteTable (
    1488   IN  PXEBC_PRIVATE_DATA            *Private,
    1489   IN  UINTN                         TimeOutInSecond,
    1490   OUT EFI_IPv6_ADDRESS              *GatewayAddr
     1489  IN  PXEBC_PRIVATE_DATA  *Private,
     1490  IN  UINTN               TimeOutInSecond,
     1491  OUT EFI_IPv6_ADDRESS    *GatewayAddr
    14911492  )
    14921493{
    1493   EFI_STATUS                       Status;
    1494   EFI_IP6_PROTOCOL                 *Ip6;
    1495   EFI_IP6_MODE_DATA                Ip6ModeData;
    1496   UINTN                            Index;
    1497   EFI_EVENT                        TimeOutEvt;
    1498   UINTN                            RetryCount;
    1499   BOOLEAN                          GatewayIsFound;
     1494  EFI_STATUS         Status;
     1495  EFI_IP6_PROTOCOL   *Ip6;
     1496  EFI_IP6_MODE_DATA  Ip6ModeData;
     1497  UINTN              Index;
     1498  EFI_EVENT          TimeOutEvt;
     1499  UINTN              RetryCount;
     1500  BOOLEAN            GatewayIsFound;
    15001501
    15011502  ASSERT (GatewayAddr != NULL);
     
    15281529      FreePool (Ip6ModeData.AddressList);
    15291530    }
     1531
    15301532    if (Ip6ModeData.GroupTable != NULL) {
    15311533      FreePool (Ip6ModeData.GroupTable);
    15321534    }
     1535
    15331536    if (Ip6ModeData.RouteTable != NULL) {
    15341537      FreePool (Ip6ModeData.RouteTable);
    15351538    }
     1539
    15361540    if (Ip6ModeData.NeighborCache != NULL) {
    15371541      FreePool (Ip6ModeData.NeighborCache);
    15381542    }
     1543
    15391544    if (Ip6ModeData.PrefixTable != NULL) {
    15401545      FreePool (Ip6ModeData.PrefixTable);
    15411546    }
     1547
    15421548    if (Ip6ModeData.IcmpTypeList != NULL) {
    15431549      FreePool (Ip6ModeData.IcmpTypeList);
    15441550    }
    15451551
    1546     if (GatewayIsFound || RetryCount == TimeOutInSecond) {
     1552    if (GatewayIsFound || (RetryCount == TimeOutInSecond)) {
    15471553      break;
    15481554    }
     
    15701576      goto ON_EXIT;
    15711577    }
     1578
    15721579    while (EFI_ERROR (gBS->CheckEvent (TimeOutEvt))) {
    15731580      Ip6->Poll (Ip6);
     
    16011608EFI_STATUS
    16021609PxeBcRegisterIp6Address (
    1603   IN PXEBC_PRIVATE_DATA            *Private,
    1604   IN EFI_IPv6_ADDRESS              *Address
     1610  IN PXEBC_PRIVATE_DATA  *Private,
     1611  IN EFI_IPv6_ADDRESS    *Address
    16051612  )
    16061613{
    1607   EFI_IP6_PROTOCOL                 *Ip6;
    1608   EFI_IP6_CONFIG_PROTOCOL          *Ip6Cfg;
    1609   EFI_IP6_CONFIG_POLICY            Policy;
    1610   EFI_IP6_CONFIG_MANUAL_ADDRESS    CfgAddr;
    1611   EFI_IPv6_ADDRESS                 GatewayAddr;
    1612   UINTN                            DataSize;
    1613   EFI_EVENT                        MappedEvt;
    1614   EFI_STATUS                       Status;
    1615   BOOLEAN                          NoGateway;
    1616   EFI_IPv6_ADDRESS                 *Ip6Addr;
    1617   UINTN                            Index;
    1618 
    1619   Status     = EFI_SUCCESS;
    1620   MappedEvt  = NULL;
    1621   Ip6Addr    = NULL;
    1622   DataSize   = sizeof (EFI_IP6_CONFIG_POLICY);
    1623   Ip6Cfg     = Private->Ip6Cfg;
    1624   Ip6        = Private->Ip6;
    1625   NoGateway  = FALSE;
     1614  EFI_IP6_PROTOCOL               *Ip6;
     1615  EFI_IP6_CONFIG_PROTOCOL        *Ip6Cfg;
     1616  EFI_IP6_CONFIG_POLICY          Policy;
     1617  EFI_IP6_CONFIG_MANUAL_ADDRESS  CfgAddr;
     1618  EFI_IPv6_ADDRESS               GatewayAddr;
     1619  UINTN                          DataSize;
     1620  EFI_EVENT                      MappedEvt;
     1621  EFI_STATUS                     Status;
     1622  BOOLEAN                        NoGateway;
     1623  EFI_IPv6_ADDRESS               *Ip6Addr;
     1624  UINTN                          Index;
     1625
     1626  Status    = EFI_SUCCESS;
     1627  MappedEvt = NULL;
     1628  Ip6Addr   = NULL;
     1629  DataSize  = sizeof (EFI_IP6_CONFIG_POLICY);
     1630  Ip6Cfg    = Private->Ip6Cfg;
     1631  Ip6       = Private->Ip6;
     1632  NoGateway = FALSE;
    16261633
    16271634  ZeroMem (&CfgAddr, sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS));
     
    16491656                     Ip6Cfg,
    16501657                     Ip6ConfigDataTypePolicy,
    1651                      sizeof(EFI_IP6_CONFIG_POLICY),
     1658                     sizeof (EFI_IP6_CONFIG_POLICY),
    16521659                     &Policy
    16531660                     );
     
    16751682
    16761683  Private->IsAddressOk = FALSE;
    1677   Status = Ip6Cfg->RegisterDataNotify (
    1678                      Ip6Cfg,
    1679                      Ip6ConfigDataTypeManualAddress,
    1680                      MappedEvt
    1681                      );
    1682   if (EFI_ERROR(Status)) {
     1684  Status               = Ip6Cfg->RegisterDataNotify (
     1685                                   Ip6Cfg,
     1686                                   Ip6ConfigDataTypeManualAddress,
     1687                                   MappedEvt
     1688                                   );
     1689  if (EFI_ERROR (Status)) {
    16831690    goto ON_EXIT;
    16841691  }
     
    16871694                     Ip6Cfg,
    16881695                     Ip6ConfigDataTypeManualAddress,
    1689                      sizeof(EFI_IP6_CONFIG_MANUAL_ADDRESS),
     1696                     sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS),
    16901697                     &CfgAddr
    16911698                     );
    1692   if (EFI_ERROR(Status) && Status != EFI_NOT_READY) {
     1699  if (EFI_ERROR (Status) && (Status != EFI_NOT_READY)) {
    16931700    goto ON_EXIT;
    16941701  } else if (Status == EFI_NOT_READY) {
     
    16991706      Ip6->Poll (Ip6);
    17001707    }
     1708
    17011709    //
    17021710    // Check whether the IP6 address setting is successed.
    17031711    //
    17041712    DataSize = 0;
     1713    Status   = Ip6Cfg->GetData (
     1714                         Ip6Cfg,
     1715                         Ip6ConfigDataTypeManualAddress,
     1716                         &DataSize,
     1717                         NULL
     1718                         );
     1719    if ((Status != EFI_BUFFER_TOO_SMALL) || (DataSize == 0)) {
     1720      Status = EFI_DEVICE_ERROR;
     1721      goto ON_EXIT;
     1722    }
     1723
     1724    Ip6Addr = AllocatePool (DataSize);
     1725    if (Ip6Addr == NULL) {
     1726      return EFI_OUT_OF_RESOURCES;
     1727    }
     1728
    17051729    Status = Ip6Cfg->GetData (
    17061730                       Ip6Cfg,
    17071731                       Ip6ConfigDataTypeManualAddress,
    17081732                       &DataSize,
    1709                        NULL
    1710                        );
    1711     if (Status != EFI_BUFFER_TOO_SMALL || DataSize == 0) {
    1712       Status = EFI_DEVICE_ERROR;
    1713       goto ON_EXIT;
    1714     }
    1715 
    1716     Ip6Addr = AllocatePool (DataSize);
    1717     if (Ip6Addr == NULL) {
    1718       return EFI_OUT_OF_RESOURCES;
    1719     }
    1720     Status = Ip6Cfg->GetData (
    1721                        Ip6Cfg,
    1722                        Ip6ConfigDataTypeManualAddress,
    1723                        &DataSize,
    1724                        (VOID*) Ip6Addr
     1733                       (VOID *)Ip6Addr
    17251734                       );
    17261735    if (EFI_ERROR (Status)) {
     
    17341743      }
    17351744    }
     1745
    17361746    if (Index == DataSize / sizeof (EFI_IPv6_ADDRESS)) {
    17371747      Status = EFI_ABORTED;
     
    17641774    gBS->CloseEvent (MappedEvt);
    17651775  }
     1776
    17661777  if (Ip6Addr != NULL) {
    17671778    FreePool (Ip6Addr);
    17681779  }
     1780
    17691781  return Status;
    17701782}
     
    17811793EFI_STATUS
    17821794PxeBcSetIp6Policy (
    1783   IN PXEBC_PRIVATE_DATA            *Private
     1795  IN PXEBC_PRIVATE_DATA  *Private
    17841796  )
    17851797{
    1786   EFI_IP6_CONFIG_POLICY            Policy;
    1787   EFI_STATUS                       Status;
    1788   EFI_IP6_CONFIG_PROTOCOL          *Ip6Cfg;
    1789   UINTN                            DataSize;
    1790 
    1791   Ip6Cfg      = Private->Ip6Cfg;
    1792   DataSize    = sizeof (EFI_IP6_CONFIG_POLICY);
     1798  EFI_IP6_CONFIG_POLICY    Policy;
     1799  EFI_STATUS               Status;
     1800  EFI_IP6_CONFIG_PROTOCOL  *Ip6Cfg;
     1801  UINTN                    DataSize;
     1802
     1803  Ip6Cfg   = Private->Ip6Cfg;
     1804  DataSize = sizeof (EFI_IP6_CONFIG_POLICY);
    17931805
    17941806  //
     
    18101822                       Ip6Cfg,
    18111823                       Ip6ConfigDataTypePolicy,
    1812                        sizeof(EFI_IP6_CONFIG_POLICY),
     1824                       sizeof (EFI_IP6_CONFIG_POLICY),
    18131825                       &Policy
    18141826                       );
     
    18351847EFI_STATUS
    18361848PxeBcSetIp6Address (
    1837   IN  PXEBC_PRIVATE_DATA              *Private
     1849  IN  PXEBC_PRIVATE_DATA  *Private
    18381850  )
    18391851{
    1840   EFI_STATUS                  Status;
    1841   EFI_DHCP6_PROTOCOL          *Dhcp6;
     1852  EFI_STATUS          Status;
     1853  EFI_DHCP6_PROTOCOL  *Dhcp6;
    18421854
    18431855  Dhcp6 = Private->Dhcp6;
     
    18861898EFIAPI
    18871899PxeBcDhcp6CallBack (
    1888   IN  EFI_DHCP6_PROTOCOL           *This,
    1889   IN  VOID                         *Context,
    1890   IN  EFI_DHCP6_STATE              CurrentState,
    1891   IN  EFI_DHCP6_EVENT              Dhcp6Event,
    1892   IN  EFI_DHCP6_PACKET             *Packet,
    1893   OUT EFI_DHCP6_PACKET             **NewPacket     OPTIONAL
     1900  IN  EFI_DHCP6_PROTOCOL  *This,
     1901  IN  VOID                *Context,
     1902  IN  EFI_DHCP6_STATE     CurrentState,
     1903  IN  EFI_DHCP6_EVENT     Dhcp6Event,
     1904  IN  EFI_DHCP6_PACKET    *Packet,
     1905  OUT EFI_DHCP6_PACKET    **NewPacket     OPTIONAL
    18941906  )
    18951907{
    1896   PXEBC_PRIVATE_DATA                  *Private;
    1897   EFI_PXE_BASE_CODE_MODE              *Mode;
    1898   EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *Callback;
    1899   EFI_DHCP6_PACKET                    *SelectAd;
    1900   EFI_STATUS                          Status;
    1901   BOOLEAN                             Received;
     1908  PXEBC_PRIVATE_DATA                   *Private;
     1909  EFI_PXE_BASE_CODE_MODE               *Mode;
     1910  EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL  *Callback;
     1911  EFI_DHCP6_PACKET                     *SelectAd;
     1912  EFI_STATUS                           Status;
     1913  BOOLEAN                              Received;
    19021914
    19031915  if ((Dhcp6Event != Dhcp6RcvdAdvertise) &&
     
    19051917      (Dhcp6Event != Dhcp6SendSolicit) &&
    19061918      (Dhcp6Event != Dhcp6SendRequest) &&
    1907       (Dhcp6Event != Dhcp6RcvdReply)) {
     1919      (Dhcp6Event != Dhcp6RcvdReply))
     1920  {
    19081921    return EFI_SUCCESS;
    19091922  }
     
    19111924  ASSERT (Packet != NULL);
    19121925
    1913   Private   = (PXEBC_PRIVATE_DATA *) Context;
    1914   Mode      = Private->PxeBc.Mode;
    1915   Callback  = Private->PxeBcCallback;
     1926  Private  = (PXEBC_PRIVATE_DATA *)Context;
     1927  Mode     = Private->PxeBc.Mode;
     1928  Callback = Private->PxeBcCallback;
    19161929
    19171930  //
    19181931  // Callback to user when any traffic occurred if has.
    19191932  //
    1920   if (Dhcp6Event != Dhcp6SelectAdvertise && Callback != NULL) {
    1921     Received = (BOOLEAN) (Dhcp6Event == Dhcp6RcvdAdvertise || Dhcp6Event == Dhcp6RcvdReply);
    1922     Status = Callback->Callback (
    1923                          Callback,
    1924                          Private->Function,
    1925                          Received,
    1926                          Packet->Length,
    1927                          (EFI_PXE_BASE_CODE_PACKET *) &Packet->Dhcp6
    1928                          );
     1933  if ((Dhcp6Event != Dhcp6SelectAdvertise) && (Callback != NULL)) {
     1934    Received = (BOOLEAN)(Dhcp6Event == Dhcp6RcvdAdvertise || Dhcp6Event == Dhcp6RcvdReply);
     1935    Status   = Callback->Callback (
     1936                           Callback,
     1937                           Private->Function,
     1938                           Received,
     1939                           Packet->Length,
     1940                           (EFI_PXE_BASE_CODE_PACKET *)&Packet->Dhcp6
     1941                           );
    19291942    if (Status != EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE) {
    19301943      return EFI_ABORTED;
     
    19351948
    19361949  switch (Dhcp6Event) {
    1937 
    1938   case Dhcp6SendSolicit:
    1939     if (Packet->Length > PXEBC_DHCP6_PACKET_MAX_SIZE) {
    1940       //
    1941       // If the to be sent packet exceeds the maximum length, abort the DHCP process.
    1942       //
    1943       Status = EFI_ABORTED;
     1950    case Dhcp6SendSolicit:
     1951      if (Packet->Length > PXEBC_DHCP6_PACKET_MAX_SIZE) {
     1952        //
     1953        // If the to be sent packet exceeds the maximum length, abort the DHCP process.
     1954        //
     1955        Status = EFI_ABORTED;
     1956        break;
     1957      }
     1958
     1959      //
     1960      // Record the first Solicate msg time
     1961      //
     1962      if (Private->SolicitTimes == 0) {
     1963        CalcElapsedTime (Private);
     1964        Private->SolicitTimes++;
     1965      }
     1966
     1967      //
     1968      // Cache the dhcp discover packet to mode data directly.
     1969      //
     1970      CopyMem (&Mode->DhcpDiscover.Dhcpv4, &Packet->Dhcp6, Packet->Length);
    19441971      break;
    1945     }
    1946 
    1947     //
    1948     // Record the first Solicate msg time
    1949     //
    1950     if (Private->SolicitTimes == 0) {
    1951       CalcElapsedTime (Private);
    1952       Private->SolicitTimes++;
    1953     }
    1954     //
    1955     // Cache the dhcp discover packet to mode data directly.
    1956     //
    1957     CopyMem (&Mode->DhcpDiscover.Dhcpv4, &Packet->Dhcp6, Packet->Length);
    1958     break;
    1959 
    1960   case Dhcp6RcvdAdvertise:
    1961     Status = EFI_NOT_READY;
    1962     if (Packet->Length > PXEBC_DHCP6_PACKET_MAX_SIZE) {
    1963       //
    1964       // Ignore the incoming packets which exceed the maximum length.
    1965       //
     1972
     1973    case Dhcp6RcvdAdvertise:
     1974      Status = EFI_NOT_READY;
     1975      if (Packet->Length > PXEBC_DHCP6_PACKET_MAX_SIZE) {
     1976        //
     1977        // Ignore the incoming packets which exceed the maximum length.
     1978        //
     1979        break;
     1980      }
     1981
     1982      if (Private->OfferNum < PXEBC_OFFER_MAX_NUM) {
     1983        //
     1984        // Cache the dhcp offers to OfferBuffer[] for select later, and record
     1985        // the OfferIndex and OfferCount.
     1986        //
     1987        PxeBcCacheDhcp6Offer (Private, Packet);
     1988      }
     1989
    19661990      break;
    1967     }
    1968     if (Private->OfferNum < PXEBC_OFFER_MAX_NUM) {
    1969       //
    1970       // Cache the dhcp offers to OfferBuffer[] for select later, and record
    1971       // the OfferIndex and OfferCount.
    1972       //
    1973       PxeBcCacheDhcp6Offer (Private, Packet);
    1974     }
    1975     break;
    1976 
    1977   case Dhcp6SendRequest:
    1978     if (Packet->Length > PXEBC_DHCP6_PACKET_MAX_SIZE) {
    1979       //
    1980       // If the to be sent packet exceeds the maximum length, abort the DHCP process.
    1981       //
    1982       Status = EFI_ABORTED;
     1991
     1992    case Dhcp6SendRequest:
     1993      if (Packet->Length > PXEBC_DHCP6_PACKET_MAX_SIZE) {
     1994        //
     1995        // If the to be sent packet exceeds the maximum length, abort the DHCP process.
     1996        //
     1997        Status = EFI_ABORTED;
     1998        break;
     1999      }
     2000
     2001      //
     2002      // Store the request packet as seed packet for discover.
     2003      //
     2004      if (Private->Dhcp6Request != NULL) {
     2005        FreePool (Private->Dhcp6Request);
     2006      }
     2007
     2008      Private->Dhcp6Request = AllocateZeroPool (Packet->Size);
     2009      if (Private->Dhcp6Request != NULL) {
     2010        CopyMem (Private->Dhcp6Request, Packet, Packet->Size);
     2011      }
     2012
    19832013      break;
    1984     }
    1985 
    1986     //
    1987     // Store the request packet as seed packet for discover.
    1988     //
    1989     if (Private->Dhcp6Request != NULL) {
    1990       FreePool (Private->Dhcp6Request);
    1991     }
    1992     Private->Dhcp6Request = AllocateZeroPool (Packet->Size);
    1993     if (Private->Dhcp6Request != NULL) {
    1994       CopyMem (Private->Dhcp6Request, Packet, Packet->Size);
    1995     }
    1996     break;
    1997 
    1998   case Dhcp6SelectAdvertise:
    1999     //
    2000     // Select offer by the default policy or by order, and record the SelectIndex
    2001     // and SelectProxyType.
    2002     //
    2003     PxeBcSelectDhcp6Offer (Private);
    2004 
    2005     if (Private->SelectIndex == 0) {
    2006       Status = EFI_ABORTED;
    2007     } else {
    2008       ASSERT (NewPacket != NULL);
    2009       SelectAd   = &Private->OfferBuffer[Private->SelectIndex - 1].Dhcp6.Packet.Offer;
    2010       *NewPacket = AllocateZeroPool (SelectAd->Size);
    2011       ASSERT (*NewPacket != NULL);
    2012       if (*NewPacket == NULL) {
    2013         return EFI_ABORTED;
     2014
     2015    case Dhcp6SelectAdvertise:
     2016      //
     2017      // Select offer by the default policy or by order, and record the SelectIndex
     2018      // and SelectProxyType.
     2019      //
     2020      PxeBcSelectDhcp6Offer (Private);
     2021
     2022      if (Private->SelectIndex == 0) {
     2023        Status = EFI_ABORTED;
     2024      } else {
     2025        ASSERT (NewPacket != NULL);
     2026        SelectAd   = &Private->OfferBuffer[Private->SelectIndex - 1].Dhcp6.Packet.Offer;
     2027        *NewPacket = AllocateZeroPool (SelectAd->Size);
     2028        ASSERT (*NewPacket != NULL);
     2029        if (*NewPacket == NULL) {
     2030          return EFI_ABORTED;
     2031        }
     2032
     2033        CopyMem (*NewPacket, SelectAd, SelectAd->Size);
    20142034      }
    2015       CopyMem (*NewPacket, SelectAd, SelectAd->Size);
    2016     }
    2017     break;
    2018 
    2019   case Dhcp6RcvdReply:
    2020     //
    2021     // Cache the dhcp ack to Private->Dhcp6Ack, but it's not the final ack in mode data
    2022     // without verification.
    2023     //
    2024     ASSERT (Private->SelectIndex != 0);
    2025     Status = PxeBcCopyDhcp6Ack (Private, Packet, FALSE);
    2026     if (EFI_ERROR (Status)) {
    2027       Status = EFI_ABORTED;
    2028     }
    2029     break;
    2030 
    2031   default:
    2032     ASSERT (0);
     2035
     2036      break;
     2037
     2038    case Dhcp6RcvdReply:
     2039      //
     2040      // Cache the dhcp ack to Private->Dhcp6Ack, but it's not the final ack in mode data
     2041      // without verification.
     2042      //
     2043      ASSERT (Private->SelectIndex != 0);
     2044      Status = PxeBcCopyDhcp6Ack (Private, Packet, FALSE);
     2045      if (EFI_ERROR (Status)) {
     2046        Status = EFI_ABORTED;
     2047      }
     2048
     2049      break;
     2050
     2051    default:
     2052      ASSERT (0);
    20332053  }
    20342054
    20352055  return Status;
    20362056}
    2037 
    20382057
    20392058/**
     
    20542073EFI_STATUS
    20552074PxeBcDhcp6Discover (
    2056   IN  PXEBC_PRIVATE_DATA              *Private,
    2057   IN  UINT16                          Type,
    2058   IN  UINT16                          *Layer,
    2059   IN  BOOLEAN                         UseBis,
    2060   IN  EFI_IP_ADDRESS                  *DestIp
     2075  IN  PXEBC_PRIVATE_DATA  *Private,
     2076  IN  UINT16              Type,
     2077  IN  UINT16              *Layer,
     2078  IN  BOOLEAN             UseBis,
     2079  IN  EFI_IP_ADDRESS      *DestIp
    20612080  )
    20622081{
    2063   EFI_PXE_BASE_CODE_UDP_PORT          SrcPort;
    2064   EFI_PXE_BASE_CODE_UDP_PORT          DestPort;
    2065   EFI_PXE_BASE_CODE_MODE              *Mode;
    2066   EFI_PXE_BASE_CODE_PROTOCOL          *PxeBc;
    2067   EFI_PXE_BASE_CODE_DHCPV6_PACKET     *Discover;
    2068   UINTN                               DiscoverLen;
    2069   EFI_DHCP6_PACKET                    *Request;
    2070   UINTN                               RequestLen;
    2071   EFI_DHCP6_PACKET                    *Reply;
    2072   UINT8                               *RequestOpt;
    2073   UINT8                               *DiscoverOpt;
    2074   UINTN                               ReadSize;
    2075   UINT16                              OpCode;
    2076   UINT16                              OpLen;
    2077   UINT32                              Xid;
    2078   EFI_STATUS                          Status;
    2079 
    2080   PxeBc       = &Private->PxeBc;
    2081   Mode        = PxeBc->Mode;
    2082   Request     = Private->Dhcp6Request;
    2083   SrcPort     = PXEBC_BS_DISCOVER_PORT;
    2084   DestPort    = PXEBC_BS_DISCOVER_PORT;
    2085 
    2086   if (!UseBis && Layer != NULL) {
     2082  EFI_PXE_BASE_CODE_UDP_PORT       SrcPort;
     2083  EFI_PXE_BASE_CODE_UDP_PORT       DestPort;
     2084  EFI_PXE_BASE_CODE_MODE           *Mode;
     2085  EFI_PXE_BASE_CODE_PROTOCOL       *PxeBc;
     2086  EFI_PXE_BASE_CODE_DHCPV6_PACKET  *Discover;
     2087  UINTN                            DiscoverLen;
     2088  EFI_DHCP6_PACKET                 *Request;
     2089  UINTN                            RequestLen;
     2090  EFI_DHCP6_PACKET                 *Reply;
     2091  UINT8                            *RequestOpt;
     2092  UINT8                            *DiscoverOpt;
     2093  UINTN                            ReadSize;
     2094  UINT16                           OpCode;
     2095  UINT16                           OpLen;
     2096  UINT32                           Xid;
     2097  EFI_STATUS                       Status;
     2098
     2099  PxeBc    = &Private->PxeBc;
     2100  Mode     = PxeBc->Mode;
     2101  Request  = Private->Dhcp6Request;
     2102  SrcPort  = PXEBC_BS_DISCOVER_PORT;
     2103  DestPort = PXEBC_BS_DISCOVER_PORT;
     2104
     2105  if (!UseBis && (Layer != NULL)) {
    20872106    *Layer &= EFI_PXE_BASE_CODE_BOOT_LAYER_MASK;
    20882107  }
     
    21092128
    21102129  while (RequestLen < Request->Length) {
    2111     OpCode = NTOHS (((EFI_DHCP6_PACKET_OPTION *) RequestOpt)->OpCode);
    2112     OpLen  = NTOHS (((EFI_DHCP6_PACKET_OPTION *) RequestOpt)->OpLen);
    2113     if (OpCode != EFI_DHCP6_IA_TYPE_NA &&
    2114         OpCode != EFI_DHCP6_IA_TYPE_TA) {
     2130    OpCode = NTOHS (((EFI_DHCP6_PACKET_OPTION *)RequestOpt)->OpCode);
     2131    OpLen  = NTOHS (((EFI_DHCP6_PACKET_OPTION *)RequestOpt)->OpLen);
     2132    if ((OpCode != EFI_DHCP6_IA_TYPE_NA) &&
     2133        (OpCode != EFI_DHCP6_IA_TYPE_TA))
     2134    {
    21152135      //
    21162136      // Copy all the options except IA option.
     
    21202140      DiscoverLen += (OpLen + 4);
    21212141    }
     2142
    21222143    RequestOpt += (OpLen + 4);
    21232144    RequestLen += (OpLen + 4);
     
    21352156                    NULL,
    21362157                    &DiscoverLen,
    2137                     (VOID *) Discover
     2158                    (VOID *)Discover
    21382159                    );
    21392160  if (EFI_ERROR (Status)) {
     
    21512172    Reply = &Private->ProxyOffer.Dhcp6.Packet.Offer;
    21522173  }
    2153   ReadSize = (UINTN) Reply->Size;
     2174
     2175  ReadSize = (UINTN)Reply->Size;
    21542176
    21552177  //
     
    21712193                    NULL,
    21722194                    &ReadSize,
    2173                     (VOID *) &Reply->Dhcp6
     2195                    (VOID *)&Reply->Dhcp6
    21742196                    );
    21752197  //
     
    21912213}
    21922214
    2193 
    21942215/**
    21952216  Start the DHCPv6 S.A.R.R. process to acquire the IPv6 address and other PXE boot information.
     
    22042225EFI_STATUS
    22052226PxeBcDhcp6Sarr (
    2206   IN PXEBC_PRIVATE_DATA            *Private,
    2207   IN EFI_DHCP6_PROTOCOL            *Dhcp6
     2227  IN PXEBC_PRIVATE_DATA  *Private,
     2228  IN EFI_DHCP6_PROTOCOL  *Dhcp6
    22082229  )
    22092230{
    2210   EFI_PXE_BASE_CODE_MODE           *PxeMode;
    2211   EFI_DHCP6_CONFIG_DATA            Config;
    2212   EFI_DHCP6_MODE_DATA              Mode;
    2213   EFI_DHCP6_RETRANSMISSION         *Retransmit;
    2214   EFI_DHCP6_PACKET_OPTION          *OptList[PXEBC_DHCP6_OPTION_MAX_NUM];
    2215   UINT8                            Buffer[PXEBC_DHCP6_OPTION_MAX_SIZE];
    2216   UINT32                           OptCount;
    2217   EFI_STATUS                       Status;
    2218   EFI_IP6_CONFIG_PROTOCOL          *Ip6Cfg;
    2219   EFI_STATUS                       TimerStatus;
    2220   EFI_EVENT                        Timer;
    2221   UINT64                           GetMappingTimeOut;
    2222   UINTN                            DataSize;
    2223   EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS    DadXmits;
    2224 
    2225   Status     = EFI_SUCCESS;
    2226   PxeMode    = Private->PxeBc.Mode;
    2227   Ip6Cfg     = Private->Ip6Cfg;
    2228   Timer      = NULL;
     2231  EFI_PXE_BASE_CODE_MODE                    *PxeMode;
     2232  EFI_DHCP6_CONFIG_DATA                     Config;
     2233  EFI_DHCP6_MODE_DATA                       Mode;
     2234  EFI_DHCP6_RETRANSMISSION                  *Retransmit;
     2235  EFI_DHCP6_PACKET_OPTION                   *OptList[PXEBC_DHCP6_OPTION_MAX_NUM];
     2236  UINT8                                     Buffer[PXEBC_DHCP6_OPTION_MAX_SIZE];
     2237  UINT32                                    OptCount;
     2238  EFI_STATUS                                Status;
     2239  EFI_IP6_CONFIG_PROTOCOL                   *Ip6Cfg;
     2240  EFI_STATUS                                TimerStatus;
     2241  EFI_EVENT                                 Timer;
     2242  UINT64                                    GetMappingTimeOut;
     2243  UINTN                                     DataSize;
     2244  EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS  DadXmits;
     2245
     2246  Status  = EFI_SUCCESS;
     2247  PxeMode = Private->PxeBc.Mode;
     2248  Ip6Cfg  = Private->Ip6Cfg;
     2249  Timer   = NULL;
    22292250
    22302251  //
    22312252  // Build option list for the request packet.
    22322253  //
    2233   OptCount   = PxeBcBuildDhcp6Options (Private, OptList, Buffer);
    2234   ASSERT (OptCount> 0);
     2254  OptCount = PxeBcBuildDhcp6Options (Private, OptList, Buffer);
     2255  ASSERT (OptCount > 0);
    22352256
    22362257  Retransmit = AllocateZeroPool (sizeof (EFI_DHCP6_RETRANSMISSION));
     
    22752296  ZeroMem (Private->OfferIndex, sizeof (Private->OfferIndex));
    22762297
    2277 
    22782298  //
    22792299  // Start DHCPv6 S.A.R.R. process to acquire IPv6 address.
     
    22912311    //
    22922312    DataSize = sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS);
    2293     Status = Ip6Cfg->GetData (
    2294                        Ip6Cfg,
    2295                        Ip6ConfigDataTypeDupAddrDetectTransmits,
    2296                        &DataSize,
    2297                        &DadXmits
    2298                        );
     2313    Status   = Ip6Cfg->GetData (
     2314                         Ip6Cfg,
     2315                         Ip6ConfigDataTypeDupAddrDetectTransmits,
     2316                         &DataSize,
     2317                         &DadXmits
     2318                         );
    22992319    if (EFI_ERROR (Status)) {
    23002320      Dhcp6->Configure (Dhcp6, NULL);
     
    23092329
    23102330    GetMappingTimeOut = TICKS_PER_SECOND * DadXmits.DupAddrDetectTransmits + PXEBC_DAD_ADDITIONAL_DELAY;
    2311     Status = gBS->SetTimer (Timer, TimerRelative, GetMappingTimeOut);
     2331    Status            = gBS->SetTimer (Timer, TimerRelative, GetMappingTimeOut);
    23122332    if (EFI_ERROR (Status)) {
    23132333      gBS->CloseEvent (Timer);
     
    23172337
    23182338    do {
    2319 
    23202339      TimerStatus = gBS->CheckEvent (Timer);
    23212340      if (!EFI_ERROR (TimerStatus)) {
     
    23262345    gBS->CloseEvent (Timer);
    23272346  }
     2347
    23282348  if (EFI_ERROR (Status)) {
    23292349    if (Status == EFI_ICMP_ERROR) {
    23302350      PxeMode->IcmpErrorReceived = TRUE;
    23312351    }
     2352
    23322353    Dhcp6->Configure (Dhcp6, NULL);
    23332354    return Status;
     
    23552376    FreePool (Mode.ClientId);
    23562377  }
     2378
    23572379  if (Mode.Ia != NULL) {
    23582380    FreePool (Mode.Ia);
    23592381  }
     2382
    23602383  //
    23612384  // Check the selected offer whether BINL retry is needed.
Note: See TracChangeset for help on using the changeset viewer.

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