[edk2] [Patch 3/4] MdeModulePkg/UefiBootManagerLib: Support DNS device path description

2017-07-25 Thread Jiaxin Wu
This patch is to update UEFI Boot manager to support DNS device path
for HTTP(S) network boot.

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c 
b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
index 6e69a15..7647bac 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
@@ -385,12 +385,12 @@ BmGetNetworkDescription (
   //   ../Mac(...)[/Vlan(...)][/Wi-Fi(...)]
   //   ../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv4(...)
   //   ../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv6(...)
   //
   // The HTTP device path is like:
-  //   ../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv4(...)/Uri(...)
-  //   ../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv6(...)/Uri(...)
+  //   ../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv4(...)[/Dns(...)]/Uri(...)
+  //   ../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv6(...)[/Dns(...)]/Uri(...)
   //
   while (!IsDevicePathEnd (DevicePath) &&
  ((DevicePathType (DevicePath) != MESSAGING_DEVICE_PATH) ||
   (DevicePathSubType (DevicePath) != MSG_MAC_ADDR_DP))
  ) {
@@ -435,10 +435,19 @@ BmGetNetworkDescription (
 Ip = DevicePath;
 DevicePath = NextDevicePathNode (DevicePath);
   } else {
 Ip = NULL;
   }
+  
+  //
+  // Skip the optional DNS node
+  //
+  if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&
+  (DevicePathSubType (DevicePath) == MSG_DNS_DP)
+  ) {
+DevicePath = NextDevicePathNode (DevicePath);
+  }
 
   //
   // Locate the URI node
   //
   if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 4/4] NetworkPkg/HttpBootDxe: Update device path node to include DNS information

2017-07-25 Thread Jiaxin Wu
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/HttpBootDxe/HttpBootClient.c | 138 ++--
 NetworkPkg/HttpBootDxe/HttpBootDxe.h|   2 +
 NetworkPkg/HttpBootDxe/HttpBootImpl.c   |   7 +-
 3 files changed, 122 insertions(+), 25 deletions(-)

diff --git a/NetworkPkg/HttpBootDxe/HttpBootClient.c 
b/NetworkPkg/HttpBootDxe/HttpBootClient.c
index 68f5a49..5c87171 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootClient.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootClient.c
@@ -14,11 +14,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 **/
 
 #include "HttpBootDxe.h"
 
 /**
-  Update the IP and URL device path node to include the boot resource 
information.
+  Update the device path node to include the boot resource information.
 
   @param[in]PrivateThe pointer to the driver's private data.
 
   @retval EFI_SUCCESS  Device patch successfully updated.
   @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources.
@@ -29,16 +29,18 @@ EFI_STATUS
 HttpBootUpdateDevicePath (
   IN   HTTP_BOOT_PRIVATE_DATA   *Private
   )
 {
   EFI_DEV_PATH   *Node;
-  EFI_DEVICE_PATH_PROTOCOL   *TmpDevicePath;
+  EFI_DEVICE_PATH_PROTOCOL   *TmpIpDevicePath;
+  EFI_DEVICE_PATH_PROTOCOL   *TmpDnsDevicePath;
   EFI_DEVICE_PATH_PROTOCOL   *NewDevicePath;
   UINTN  Length;
   EFI_STATUS Status;
 
-  TmpDevicePath = NULL;
+  TmpIpDevicePath  = NULL;
+  TmpDnsDevicePath = NULL;
   
   //
   // Update the IP node with DHCP assigned information.
   //
   if (!Private->UsingIpv6) {
@@ -70,33 +72,69 @@ HttpBootUpdateDevicePath (
 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);
+  TmpIpDevicePath = AppendDevicePathNode (Private->ParentDevicePath, 
(EFI_DEVICE_PATH_PROTOCOL*) Node);
   FreePool (Node);
-  if (TmpDevicePath == NULL) {
+  if (TmpIpDevicePath == NULL) {
 return EFI_OUT_OF_RESOURCES;
   }
 
   //
+  // Update the DNS node with DNS server IP list if existed.
+  //
+  if (Private->DnsServerIp != NULL) {
+Length = sizeof (EFI_DEVICE_PATH_PROTOCOL) + sizeof (Node->Dns.IsIPv6) + 
Private->DnsServerCount * sizeof (EFI_IP_ADDRESS);
+Node = AllocatePool (Length);
+if (Node == NULL) {
+  FreePool (TmpIpDevicePath);
+  return EFI_OUT_OF_RESOURCES;
+}
+Node->DevPath.Type= MESSAGING_DEVICE_PATH;
+Node->DevPath.SubType = MSG_DNS_DP;
+SetDevicePathNodeLength (Node, Length);
+Node->Dns.IsIPv6 = Private->UsingIpv6 ? 0x01 : 0x00;
+CopyMem ((UINT8*) Node + sizeof (EFI_DEVICE_PATH_PROTOCOL) + sizeof 
(Node->Dns.IsIPv6), Private->DnsServerIp, Private->DnsServerCount * sizeof 
(EFI_IP_ADDRESS));
+
+TmpDnsDevicePath = AppendDevicePathNode (TmpIpDevicePath, 
(EFI_DEVICE_PATH_PROTOCOL*) Node);
+FreePool (Node);
+FreePool (TmpIpDevicePath);
+TmpIpDevicePath = NULL;
+if (TmpDnsDevicePath == NULL) {
+  return EFI_OUT_OF_RESOURCES;
+}
+  }
+
+  //
   // Update the URI node with the boot file URI.
   //
   Length = sizeof (EFI_DEVICE_PATH_PROTOCOL) + AsciiStrSize 
(Private->BootFileUri);
   Node = AllocatePool (Length);
   if (Node == NULL) {
-FreePool (TmpDevicePath);
+if (TmpIpDevicePath != NULL) {
+  FreePool (TmpIpDevicePath);
+}
+if (TmpDnsDevicePath != NULL) {
+  FreePool (TmpDnsDevicePath);
+}
 return EFI_OUT_OF_RESOURCES;
   }
   Node->DevPath.Type= MESSAGING_DEVICE_PATH;
   Node->DevPath.SubType = MSG_URI_DP;
   SetDevicePathNodeLength (Node, Length);
   CopyMem ((UINT8*) Node + sizeof (EFI_DEVICE_PATH_PROTOCOL), 
Private->BootFileUri, AsciiStrSize (Private->BootFileUri));
-  
-  NewDevicePath = AppendDevicePathNode (TmpDevicePath, 
(EFI_DEVICE_PATH_PROTOCOL*) Node);
+
+  if (TmpDnsDevicePath != NULL) {
+NewDevicePath = AppendDevicePathNode (TmpDnsDevicePath, 
(EFI_DEVICE_PATH_PROTOCOL*) Node);
+FreePool (TmpDnsDevicePath);
+  } else {
+ASSERT (TmpIpDevicePath != NULL);
+NewDevicePath = AppendDevicePathNode (TmpIpDevicePath, 
(EFI_DEVICE_PATH_PROTOCOL*) Node);
+FreePool (TmpIpDevicePath);
+  }
   FreePool (Node);
-  FreePool (TmpDevicePath);
   if (NewDevicePath == NULL) {
 return EFI_OUT_OF_RESOURCES;
   }
 
   if (!Private->UsingIpv6) {
@@ -151,18 +189,21 @@ HttpBootDhcp4ExtractUriInfo (
 {
   HTTP_BOOT_DHCP4_PACKET_CACHE*SelectOffer;
   HTTP_BOOT_DHCP4_PACKET_CACHE*HttpOffer;
   UINT32  SelectIndex;
   UINT32  ProxyIndex;
+  UINT32  DnsServerIndex;
   EFI_DHCP4_PACKET_OPTION

[edk2] [Patch 0/2] Refine the coding style.

2017-07-25 Thread Jiaxin Wu
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 

Jiaxin Wu (2):
  MdePkg/Http.h: Refine the coding style.
  NetworkPkg/HttpDxe: Refine the coding style.

 MdePkg/Include/Protocol/Http.h | 8 
 NetworkPkg/HttpDxe/HttpImpl.c  | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 1/2] MdePkg/Http.h: Refine the coding style.

2017-07-25 Thread Jiaxin Wu
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdePkg/Include/Protocol/Http.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/MdePkg/Include/Protocol/Http.h b/MdePkg/Include/Protocol/Http.h
index f7a9aa6..8ac16ec 100644
--- a/MdePkg/Include/Protocol/Http.h
+++ b/MdePkg/Include/Protocol/Http.h
@@ -2,11 +2,11 @@
   This file defines the EFI HTTP Protocol interface. It is split into
   the following two main sections:
   HTTP Service Binding Protocol (HTTPSB)
   HTTP Protocol (HTTP)
 
-  Copyright (c) 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
   (C) Copyright 2015-2017 Hewlett Packard Enterprise Development LP
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution. The full text of the license may be 
found at
   http://opensource.org/licenses/bsd-license.php
@@ -316,11 +316,11 @@ typedef struct {
   HttpConfigData->IPv6Node is NULL.
   @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been 
started.
 **/
 typedef
 EFI_STATUS
-(EFIAPI * EFI_HTTP_GET_MODE_DATA)(
+(EFIAPI *EFI_HTTP_GET_MODE_DATA)(
   IN  EFI_HTTP_PROTOCOL *This,
   OUT EFI_HTTP_CONFIG_DATA  *HttpConfigData
   );
 
 /**
@@ -354,13 +354,13 @@ EFI_STATUS
   @retval EFI_UNSUPPORTED One or more options in ConfigData are not 
supported
   in the implementation.
 **/
 typedef
 EFI_STATUS
-(EFIAPI * EFI_HTTP_CONFIGURE)(
+(EFIAPI *EFI_HTTP_CONFIGURE)(
   IN  EFI_HTTP_PROTOCOL *This,
-  IN  EFI_HTTP_CONFIG_DATA  *HttpConfigData
+  IN  EFI_HTTP_CONFIG_DATA  *HttpConfigData OPTIONAL
   );
 
 /**
   The Request() function queues an HTTP request to this HTTP instance, 
   similar to Transmit() function in the EFI TCP driver. When the HTTP request 
is sent
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 2/2] NetworkPkg/HttpDxe: Refine the coding style.

2017-07-25 Thread Jiaxin Wu
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/HttpDxe/HttpImpl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
index 1f7a4fa..c9ad59b 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.c
+++ b/NetworkPkg/HttpDxe/HttpImpl.c
@@ -128,11 +128,11 @@ EfiHttpGetModeData (
 **/
 EFI_STATUS
 EFIAPI
 EfiHttpConfigure (
   IN  EFI_HTTP_PROTOCOL *This,
-  IN  EFI_HTTP_CONFIG_DATA  *HttpConfigData
+  IN  EFI_HTTP_CONFIG_DATA  *HttpConfigData OPTIONAL
   ) 
 {
   HTTP_PROTOCOL *HttpInstance;
   EFI_STATUSStatus;
   
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 1/3] MdePkg/Http.h: Fix spelling typo in EFI_HTTP_STATUS_CODE

2017-07-25 Thread Jiaxin Wu
"HTTP_STATUS_300_MULTIPLE_CHIOCES"
This should instead be:
"HTTP_STATUS_300_MULTIPLE_CHOICES"

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdePkg/Include/Protocol/Http.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdePkg/Include/Protocol/Http.h b/MdePkg/Include/Protocol/Http.h
index 8ac16ec..297d9c3 100644
--- a/MdePkg/Include/Protocol/Http.h
+++ b/MdePkg/Include/Protocol/Http.h
@@ -71,11 +71,11 @@ typedef enum {
   HTTP_STATUS_202_ACCEPTED,
   HTTP_STATUS_203_NON_AUTHORITATIVE_INFORMATION,
   HTTP_STATUS_204_NO_CONTENT,
   HTTP_STATUS_205_RESET_CONTENT,
   HTTP_STATUS_206_PARTIAL_CONTENT,
-  HTTP_STATUS_300_MULTIPLE_CHIOCES,
+  HTTP_STATUS_300_MULTIPLE_CHOICES,
   HTTP_STATUS_301_MOVED_PERMANENTLY,
   HTTP_STATUS_302_FOUND,
   HTTP_STATUS_303_SEE_OTHER,
   HTTP_STATUS_304_NOT_MODIFIED,
   HTTP_STATUS_305_USE_PROXY,
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 2/3] MdeModulePkg/DxeHttpLib: Fix spelling typo in EFI_HTTP_STATUS_CODE

2017-07-25 Thread Jiaxin Wu
"HTTP_STATUS_300_MULTIPLE_CHIOCES"
This should instead be:
"HTTP_STATUS_300_MULTIPLE_CHOICES"

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c 
b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
index 505d5c8..caddbb7 100644
--- a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
+++ b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
@@ -1928,11 +1928,11 @@ HttpMappingToStatusCode (
   case 205:
 return HTTP_STATUS_205_RESET_CONTENT;
   case 206:
 return HTTP_STATUS_206_PARTIAL_CONTENT;
   case 300:
-return HTTP_STATUS_300_MULTIPLE_CHIOCES;
+return HTTP_STATUS_300_MULTIPLE_CHOICES;
   case 301:
 return HTTP_STATUS_301_MOVED_PERMANENTLY;
   case 302:
 return HTTP_STATUS_302_FOUND;
   case 303:
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 3/3] NetworkPkg/HttpBootDxe: Fix spelling typo in EFI_HTTP_STATUS_CODE

2017-07-25 Thread Jiaxin Wu
"HTTP_STATUS_300_MULTIPLE_CHIOCES"
This should instead be:
"HTTP_STATUS_300_MULTIPLE_CHOICES"

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/HttpBootDxe/HttpBootSupport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/NetworkPkg/HttpBootDxe/HttpBootSupport.c 
b/NetworkPkg/HttpBootDxe/HttpBootSupport.c
index 5024f2e..a19fe6c 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootSupport.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootSupport.c
@@ -158,11 +158,11 @@ HttpBootPrintErrorMessage (
   )
 {
   AsciiPrint ("\n");
 
   switch (StatusCode) {
-  case HTTP_STATUS_300_MULTIPLE_CHIOCES:
+  case HTTP_STATUS_300_MULTIPLE_CHOICES:
 AsciiPrint ("\n  Redirection: 300 Multiple Choices");
 break; 
 
   case HTTP_STATUS_301_MOVED_PERMANENTLY:
 AsciiPrint ("\n  Redirection: 301 Moved Permanently");
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 0/3] Fix spelling typo in EFI_HTTP_STATUS_CODE

2017-07-25 Thread Jiaxin Wu
"HTTP_STATUS_300_MULTIPLE_CHIOCES"
This should instead be:
"HTTP_STATUS_300_MULTIPLE_CHOICES"

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 

Jiaxin Wu (3):
  MdePkg/Http.h: Fix spelling typo in EFI_HTTP_STATUS_CODE
  MdeModulePkg/DxeHttpLib: Fix spelling typo in EFI_HTTP_STATUS_CODE
  NetworkPkg/HttpBootDxe: Fix spelling typo in EFI_HTTP_STATUS_CODE

 MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c | 2 +-
 MdePkg/Include/Protocol/Http.h   | 2 +-
 NetworkPkg/HttpBootDxe/HttpBootSupport.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v2][Patch 2/4] MdePkg/UefiDevicePathLib: Add DevPathFromTextDns and DevPathToTextDns libraries

2017-07-25 Thread Jiaxin Wu
V2:
* Add no IP instance case check.

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 .../Library/UefiDevicePathLib/DevicePathFromText.c | 80 ++
 .../Library/UefiDevicePathLib/DevicePathToText.c   | 46 +
 2 files changed, 126 insertions(+)

diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c 
b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
index f50c11c..3cdc11f 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
@@ -2723,10 +2723,89 @@ DevPathFromTextBluetoothLE (
 );
   return (EFI_DEVICE_PATH_PROTOCOL *) BluetoothLeDp;
 }
 
 /**
+  Converts a text device path node to DNS device path structure.
+
+  @param TextDeviceNode  The input Text device path node.
+
+  @return A pointer to the newly-created DNS device path structure.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextDns (
+  IN CHAR16 *TextDeviceNode
+  )
+{
+  CHAR16*DeviceNodeStr;
+  UINT32DnsServerIpCount;
+  UINT16DnsDeviceNodeLength;
+  DNS_DEVICE_PATH   *DnsDeviceNode;
+  UINT32DnsServerIpIndex;
+  CHAR16*DnsServerIp;
+
+
+  //
+  // Count the DNS server address number.
+  //
+  DeviceNodeStr= TextDeviceNode;
+  DnsServerIpCount = 0;
+  while (DeviceNodeStr != NULL && *DeviceNodeStr != L'\0') {
+GetNextParamStr (&DeviceNodeStr);
+DnsServerIpCount ++; 
+  }
+
+  //
+  // One or more instances of the DNS server address in EFI_IP_ADDRESS, 
+  // otherwise, NULL will be returned.
+  //
+  if (DnsServerIpCount == 0) {
+return NULL;
+  }
+
+  //
+  // Create the DNS DeviceNode.
+  //
+  DnsDeviceNodeLength = (UINT16) (sizeof (EFI_DEVICE_PATH_PROTOCOL) + sizeof 
(UINT8) + DnsServerIpCount * sizeof (EFI_IP_ADDRESS));
+  DnsDeviceNode   = (DNS_DEVICE_PATH *) CreateDeviceNode (
+  MESSAGING_DEVICE_PATH,
+  MSG_DNS_DP,
+  DnsDeviceNodeLength
+  );
+
+  //
+  // Confirm the DNS server address is IPv4 or IPv6 type.
+  //
+  DeviceNodeStr = TextDeviceNode;
+  while (!IS_NULL (*DeviceNodeStr)) {
+if (*DeviceNodeStr == L'.') {
+  DnsDeviceNode->IsIPv6 = 0x00;
+  break;
+}
+
+if (*DeviceNodeStr == L':') {
+  DnsDeviceNode->IsIPv6 = 0x01;
+  break;
+}
+
+DeviceNodeStr++;
+  }
+
+  for (DnsServerIpIndex = 0; DnsServerIpIndex < DnsServerIpCount; 
DnsServerIpIndex++) {
+DnsServerIp = GetNextParamStr (&TextDeviceNode);
+if (DnsDeviceNode->IsIPv6 == 0x00) {
+  StrToIpv4Address (DnsServerIp,  NULL, 
&(DnsDeviceNode->DnsServerIp[DnsServerIpIndex].v4), NULL);
+} else {
+  StrToIpv6Address (DnsServerIp, NULL, 
&(DnsDeviceNode->DnsServerIp[DnsServerIpIndex].v6), NULL);
+}
+  }
+  
+  return (EFI_DEVICE_PATH_PROTOCOL *) DnsDeviceNode;
+}
+
+/**
   Converts a text device path node to URI device path structure.
 
   @param TextDeviceNode  The input Text device path node.
 
   @return A pointer to the newly-created URI device path structure.
@@ -3395,10 +3474,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED 
DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevP
   {L"UsbTestAndMeasurement",   DevPathFromTextUsbTestAndMeasurement   },
   {L"UsbWwid", DevPathFromTextUsbWwid },
   {L"Unit",DevPathFromTextUnit},
   {L"iSCSI",   DevPathFromTextiSCSI   },
   {L"Vlan",DevPathFromTextVlan},
+  {L"Dns", DevPathFromTextDns },
   {L"Uri", DevPathFromTextUri },
   {L"Bluetooth",   DevPathFromTextBluetooth   },
   {L"Wi-Fi",   DevPathFromTextWiFi},
   {L"BluetoothLE", DevPathFromTextBluetoothLE },
   {L"MediaPath",   DevPathFromTextMediaPath   },
diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c 
b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
index b8d9491..63542db 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
@@ -1695,10 +1695,55 @@ DevPathToTextBluetoothLE (
 BluetoothLE->Address.Type
 );
 }
 
 /**
+  Converts a DNS device path structure to its string representative.
+
+  @param Str The string representative of input device.
+  @param DevPath The input device path structure.
+  @param DisplayOnly If DisplayOnly is TRUE, then the shorter text 
representation
+ of the display node is used, where applicable. If 
DisplayOnly
+ is FALSE, then the longer text representation of the 
display node
+

[edk2] [Patch 3/3] NetworkPkg/Ip6Dxe: Support SetData interface to clear specific configuration

2017-07-25 Thread Jiaxin Wu
UEFI Spec 2.7 adds the clarification on SetData interface usage to clear 
specific
individual data types. This patch is to support this feature.

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c | 692 ++
 1 file changed, 399 insertions(+), 293 deletions(-)

diff --git a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c 
b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
index 7c7acc7..9e9dc89 100644
--- a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
+++ b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
@@ -917,254 +917,333 @@ Ip6ConfigSetManualAddress (
   LIST_ENTRY *Entry2;
   IP6_INTERFACE  *IpIf;
   IP6_PREFIX_LIST_ENTRY  *PrefixEntry;
   EFI_STATUS Status;
   BOOLEANIsUpdated;
+  LIST_ENTRY *Next;
+  IP6_DAD_ENTRY  *DadEntry;
+  IP6_DELAY_JOIN_LIST*DelayNode;
+
+  NewAddress  = NULL;
+  TmpAddress  = NULL;
+  CurrentAddrInfo = NULL;
+  Copy= NULL;
+  Entry   = NULL;
+  Entry2  = NULL;
+  IpIf= NULL;
+  PrefixEntry = NULL;
+  Next= NULL;
+  DadEntry= NULL;
+  DelayNode   = NULL;
+  Status  = EFI_SUCCESS;
 
   ASSERT (Instance->DataItem[Ip6ConfigDataTypeManualAddress].Status != 
EFI_NOT_READY);
 
-  if (((DataSize % sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS)) != 0) || (DataSize 
== 0)) {
+  if ((DataSize != 0) && ((DataSize % sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS)) 
!= 0)) {
 return EFI_BAD_BUFFER_SIZE;
   }
 
   if (Instance->Policy != Ip6ConfigPolicyManual) {
 return EFI_WRITE_PROTECTED;
   }
 
-  NewAddressCount = DataSize / sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS);
-  NewAddress  = (EFI_IP6_CONFIG_MANUAL_ADDRESS *) Data;
+  IpSb = IP6_SERVICE_FROM_IP6_CONFIG_INSTANCE (Instance);
 
-  for (Index1 = 0; Index1 < NewAddressCount; Index1++, NewAddress++) {
+  DataItem = &Instance->DataItem[Ip6ConfigDataTypeManualAddress];
 
-if (NetIp6IsLinkLocalAddr (&NewAddress->Address)||
-!NetIp6IsValidUnicast (&NewAddress->Address)||
-(NewAddress->PrefixLength > 128)
-) {
-  //
-  // make sure the IPv6 address is unicast and not link-local address &&
-  // the prefix length is valid.
-  //
-  return EFI_INVALID_PARAMETER;
-}
+  if (Data != NULL && DataSize != 0) {
+NewAddressCount = DataSize / sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS);
+NewAddress  = (EFI_IP6_CONFIG_MANUAL_ADDRESS *) Data;
 
-TmpAddress = NewAddress + 1;
-for (Index2 = Index1 + 1; Index2 < NewAddressCount; Index2++, 
TmpAddress++) {
-  //
-  // Any two addresses in the array can't be equal.
-  //
-  if (EFI_IP6_EQUAL (&TmpAddress->Address, &NewAddress->Address)) {
+for (Index1 = 0; Index1 < NewAddressCount; Index1++, NewAddress++) {
 
+  if (NetIp6IsLinkLocalAddr (&NewAddress->Address)||
+  !NetIp6IsValidUnicast (&NewAddress->Address)||
+  (NewAddress->PrefixLength > 128)
+  ) {
+//
+// make sure the IPv6 address is unicast and not link-local address &&
+// the prefix length is valid.
+//
 return EFI_INVALID_PARAMETER;
   }
+
+  TmpAddress = NewAddress + 1;
+  for (Index2 = Index1 + 1; Index2 < NewAddressCount; Index2++, 
TmpAddress++) {
+//
+// Any two addresses in the array can't be equal.
+//
+if (EFI_IP6_EQUAL (&TmpAddress->Address, &NewAddress->Address)) {
+
+  return EFI_INVALID_PARAMETER;
+}
+  }
 }
-  }
 
-  IpSb = IP6_SERVICE_FROM_IP6_CONFIG_INSTANCE (Instance);
+//
+// Build the current source address list.
+//
+InitializeListHead (&CurrentSourceList);
+CurrentSourceCount = 0;
 
-  //
-  // Build the current source address list.
-  //
-  InitializeListHead (&CurrentSourceList);
-  CurrentSourceCount = 0;
+NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) {
+  IpIf = NET_LIST_USER_STRUCT_S (Entry, IP6_INTERFACE, Link, 
IP6_INTERFACE_SIGNATURE);
 
-  NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) {
-IpIf = NET_LIST_USER_STRUCT_S (Entry, IP6_INTERFACE, Link, 
IP6_INTERFACE_SIGNATURE);
+  NET_LIST_FOR_EACH (Entry2, &IpIf->AddressList) {
+CurrentAddrInfo = NET_LIST_USER_STRUCT_S (Entry2, IP6_ADDRESS_INFO, 
Link, IP6_ADDR_INFO_SIGNATURE);
 
-NET_LIST_FOR_EACH (Entry2, &IpIf->AddressList) {
-  CurrentAddrInfo = NET_LIST_USER_STRUCT_S (Entry2, IP6_ADDRESS_INFO, 
Link, IP6_ADDR_INFO_SIGNATURE);
+Copy= AllocateCopyPool (sizeof (IP6_ADDRESS_INFO), 
CurrentAddrInfo);
+if (Copy == NULL) {
+  break;
+}
 
-  Copy= AllocateCopyPool (sizeof (IP6_ADDRESS_INFO), 
CurrentAddrInfo);
-  if (Copy == NULL) {
-break;
+InsertTailList (&CurrentSourceList, &Copy->Link);
+CurrentSourceCount++;
   

[edk2] [Patch 1/3] MdePkg: Update the comments of Ip4Config2/Ip6Config Protocol

2017-07-25 Thread Jiaxin Wu
Update the comments of Ip4Config2/Ip6Config Protocol to consistent
with UEFI Spec 2.7, which provides the capability to clear specific
individual data types.

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdePkg/Include/Protocol/Ip4Config2.h | 17 +++--
 MdePkg/Include/Protocol/Ip6Config.h  | 15 ++-
 2 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/MdePkg/Include/Protocol/Ip4Config2.h 
b/MdePkg/Include/Protocol/Ip4Config2.h
index fca2bb5..ced63cb 100644
--- a/MdePkg/Include/Protocol/Ip4Config2.h
+++ b/MdePkg/Include/Protocol/Ip4Config2.h
@@ -1,10 +1,10 @@
 /** @file
   This file provides a definition of the EFI IPv4 Configuration II
   Protocol.
 
-Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -49,29 +49,35 @@ typedef enum {
   Ip4Config2DataTypePolicy,
   ///
   /// The station addresses set manually for the EFI IPv4 network 
   /// stack. It is only configurable when the policy is 
   /// Ip4Config2PolicyStatic. The corresponding Data is of 
-  /// type EFI_IP4_CONFIG2_MANUAL_ADDRESS.
+  /// type EFI_IP4_CONFIG2_MANUAL_ADDRESS. When DataSize 
+  /// is 0 and Data is NULL, the existing configuration is cleared 
+  /// from the EFI IPv4 Configuration II Protocol instance.
   ///
   Ip4Config2DataTypeManualAddress,
   ///
   /// The gateway addresses set manually for the EFI IPv4 network 
   /// stack running on the communication device this EFI IPv4 
   /// Configuration II Protocol manages. It is not configurable when 
   /// the policy is Ip4Config2PolicyDhcp. The gateway 
   /// addresses must be unicast IPv4 addresses. The corresponding 
   /// Data is a pointer to an array of EFI_IPv4_ADDRESS instances.
+  /// When DataSize is 0 and Data is NULL, the existing configuration 
+  /// is cleared from the EFI IPv4 Configuration II Protocol instance.
   ///
   Ip4Config2DataTypeGateway,
   ///
   /// The DNS server list for the EFI IPv4 network stack running on 
   /// the communication device this EFI IPv4 Configuration II 
   /// Protocol manages. It is not configurable when the policy is 
   /// Ip4Config2PolicyDhcp. The DNS server addresses must be 
   /// unicast IPv4 addresses. The corresponding Data is a pointer to 
-  /// an array of EFI_IPv4_ADDRESS instances.
+  /// an array of EFI_IPv4_ADDRESS instances. When DataSize 
+  /// is 0 and Data is NULL, the existing configuration is cleared 
+  /// from the EFI IPv4 Configuration II Protocol instance.
   ///
   Ip4Config2DataTypeDnsServer,
   Ip4Config2DataTypeMaximum
 } EFI_IP4_CONFIG2_DATA_TYPE;
 
@@ -184,13 +190,12 @@ typedef struct {
 
   @retval EFI_SUCCESS The specified configuration data for the EFI 
IPv4 network stack is set 
   successfully.
   @retval EFI_INVALID_PARAMETER   One or more of the following are TRUE:
   This is NULL.
-  Data is NULL.
-  One or more fields in Data do not match the 
requirement of the data type 
-  indicated by DataType.
+  One or more fields in Data and DataSize do 
not match the 
+  requirement of the data type indicated by 
DataType.
   @retval EFI_WRITE_PROTECTED The specified configuration data is 
read-only or the specified configuration 
   data can not be set under the current policy.
   @retval EFI_ACCESS_DENIED   Another set operation on the specified 
configuration data is already in process.
   @retval EFI_NOT_READY   An asynchronous process is invoked to set 
the specified configuration data and 
   the process is not finished yet.
diff --git a/MdePkg/Include/Protocol/Ip6Config.h 
b/MdePkg/Include/Protocol/Ip6Config.h
index b2c3be9..bcb8ba2 100644
--- a/MdePkg/Include/Protocol/Ip6Config.h
+++ b/MdePkg/Include/Protocol/Ip6Config.h
@@ -1,10 +1,10 @@
 /** @file
   This file provides a definition of the EFI IPv6 Configuration
   Protocol.
 
-Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -64,29 +64,35 @@ typedef enum {
   Ip6ConfigDataTypeDupAddrDetectTransmits,
   /// 
   /// The station add

[edk2] [Patch 0/3] Support Ip4Config2/Ip6Config.SetData interface to clear specific configuration

2017-07-25 Thread Jiaxin Wu
UEFI Spec 2.7 adds the clarification on SetData interface usage to clear 
specific
individual data types. The series patches are used to support this feature.

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 

Jiaxin Wu (3):
  MdePkg: Update the comments of Ip4Config2/Ip6Config Protocol
  MdeModulePkg/Ip4Dxe: Support SetData interface to clear specific
configuration
  NetworkPkg/Ip6Dxe: Support SetData interface to clear specific
configuration

 .../Universal/Network/Ip4Dxe/Ip4Config2Impl.c  | 285 ++---
 MdePkg/Include/Protocol/Ip4Config2.h   |  17 +-
 MdePkg/Include/Protocol/Ip6Config.h|  15 +-
 NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c  | 692 -
 4 files changed, 610 insertions(+), 399 deletions(-)

-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 2/3] MdeModulePkg/Ip4Dxe: Support SetData interface to clear specific configuration

2017-07-25 Thread Jiaxin Wu
UEFI Spec 2.7 adds the clarification on SetData interface usage to clear 
specific
individual data types. This patch is to support this feature.

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 .../Universal/Network/Ip4Dxe/Ip4Config2Impl.c  | 285 ++---
 1 file changed, 190 insertions(+), 95 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c 
b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
index 3e38085..26530e3 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
@@ -1239,63 +1239,127 @@ Ip4Config2SetManualAddress (
   EFI_STATUS Status;
   IP4_ADDR   StationAddress;
   IP4_ADDR   SubnetMask;
   VOID   *Ptr;
   IP4_SERVICE*IpSb;
+  IP4_INTERFACE  *IpIf;
+  IP4_ROUTE_TABLE*RouteTable;
+
+  DataItem   = NULL;
+  Status = EFI_SUCCESS;
+  Ptr= NULL;
+  IpIf   = NULL;
+  RouteTable = NULL;
 
   IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance);
 
   ASSERT (Instance->DataItem[Ip4Config2DataTypeManualAddress].Status != 
EFI_NOT_READY);
 
-  if (((DataSize % sizeof (EFI_IP4_CONFIG2_MANUAL_ADDRESS)) != 0) || (DataSize 
== 0)) {
+  if ((DataSize != 0) && ((DataSize % sizeof (EFI_IP4_CONFIG2_MANUAL_ADDRESS)) 
!= 0)) {
 return EFI_BAD_BUFFER_SIZE;
   }
 
   if (Instance->Policy != Ip4Config2PolicyStatic) {
 return EFI_WRITE_PROTECTED;
   }
 
-  NewAddress = *((EFI_IP4_CONFIG2_MANUAL_ADDRESS *) Data);
+  DataItem = &Instance->DataItem[Ip4Config2DataTypeManualAddress];
 
-  StationAddress = EFI_NTOHL (NewAddress.Address);
-  SubnetMask = EFI_NTOHL (NewAddress.SubnetMask);
+  if (Data != NULL && DataSize != 0) {
+NewAddress = *((EFI_IP4_CONFIG2_MANUAL_ADDRESS *) Data);
 
-  //
-  // Check whether the StationAddress/SubnetMask pair is valid.
-  //
-  if (!Ip4StationAddressValid (StationAddress, SubnetMask)) {
-return EFI_INVALID_PARAMETER;
-  }
+StationAddress = EFI_NTOHL (NewAddress.Address);
+SubnetMask = EFI_NTOHL (NewAddress.SubnetMask);
 
-  //
-  // Store the new data, and init the DataItem status to EFI_NOT_READY because
-  // we may have an asynchronous configuration process.
-  //
-  Ptr = AllocateCopyPool (DataSize, Data);
-  if (Ptr == NULL) {
-return EFI_OUT_OF_RESOURCES;
-  }
+//
+// Check whether the StationAddress/SubnetMask pair is valid.
+//
+if (!Ip4StationAddressValid (StationAddress, SubnetMask)) {
+  return EFI_INVALID_PARAMETER;
+}
 
-  DataItem = &Instance->DataItem[Ip4Config2DataTypeManualAddress];
-  if (DataItem->Data.Ptr != NULL) {
-FreePool (DataItem->Data.Ptr);
-  }
-  
-  DataItem->Data.Ptr = Ptr;
-  DataItem->DataSize = DataSize;
-  DataItem->Status   = EFI_NOT_READY;
+//
+// Store the new data, and init the DataItem status to EFI_NOT_READY 
because
+// we may have an asynchronous configuration process.
+//
+Ptr = AllocateCopyPool (DataSize, Data);
+if (Ptr == NULL) {
+  return EFI_OUT_OF_RESOURCES;
+}
 
-  IpSb->Reconfig = TRUE;
-  Status = Ip4Config2SetDefaultAddr (IpSb, StationAddress, SubnetMask);
+if (DataItem->Data.Ptr != NULL) {
+  FreePool (DataItem->Data.Ptr);
+}
+
+DataItem->Data.Ptr = Ptr;
+DataItem->DataSize = DataSize;
+DataItem->Status   = EFI_NOT_READY;
+
+IpSb->Reconfig = TRUE;
+Status = Ip4Config2SetDefaultAddr (IpSb, StationAddress, SubnetMask);
 
-  DataItem->Status = Status; 
+DataItem->Status = Status;
 
-  if (EFI_ERROR (DataItem->Status) && DataItem->Status != EFI_NOT_READY) {
-if (Ptr != NULL) {
-  FreePool (Ptr);
+if (EFI_ERROR (DataItem->Status) && DataItem->Status != EFI_NOT_READY) {
+  if (Ptr != NULL) {
+FreePool (Ptr);
+  }
+  DataItem->Data.Ptr = NULL; 
+}
+  } else {
+//
+// DataSize is 0 and Data is NULL, clean up the manual address.
+//
+if (DataItem->Data.Ptr != NULL) {
+  FreePool (DataItem->Data.Ptr);
+}
+DataItem->Data.Ptr = NULL;
+DataItem->DataSize = 0;
+DataItem->Status   = EFI_NOT_FOUND;
+
+//
+// Free the default router table and Interface, clean up the assemble 
table.
+//
+if (IpSb->DefaultInterface != NULL) {
+  if (IpSb->DefaultRouteTable != NULL) {
+Ip4FreeRouteTable (IpSb->DefaultRouteTable);
+IpSb->DefaultRouteTable = NULL;
+  }
+
+  Ip4CancelReceive (IpSb->DefaultInterface);
+
+  Ip4FreeInterface (IpSb->DefaultInterface, NULL);
+  IpSb->DefaultInterface = NULL;
+}
+
+Ip4CleanAssembleTable (&IpSb->Assemble);
+
+//
+// Create new default interface and route table.
+//
+IpIf = Ip4CreateInterface (IpSb->Mnp, IpSb->Controller, IpSb->Image);
+if (IpIf == NULL) {
+  return EFI_OUT_OF_RESOURCES;
+}
+
+  

[edk2] [Patch] NetworkPkg/Ip6Dxe: Fix the IPv6 PXE boot option goes missing issue

2017-07-30 Thread Jiaxin Wu
This patch is to fix the potential issue recorded at Bugzilla 636:
https://bugzilla.tianocore.org/show_bug.cgi?id=636

The issue is caused by the IPv6 policy switching after PXEv6 boot. When IP
policy is changing, the IPv6 children used by PXE.UdpRead() will be destroyed.
Then, PXE Stop() function is called to uninstall the devicePath protocol,
which leads to the IPv6 PXE boot option goes missing.

Through the above analysis, the IP driver should take the responsibility for
the upper layer network stacks recovery by using ConnectController().

Cc: Hegde Nagaraj P 
Cc: Subramanian Sriram 
Cc: Ni Ruiyu 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c | 72 ---
 1 file changed, 53 insertions(+), 19 deletions(-)

diff --git a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c 
b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
index 7c7acc7..f170716 100644
--- a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
+++ b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
@@ -45,16 +45,21 @@ VOID
 Ip6ConfigOnPolicyChanged (
   IN IP6_SERVICE*IpSb,
   IN EFI_IP6_CONFIG_POLICY  NewPolicy
   )
 {
-  LIST_ENTRY  *Entry;
-  LIST_ENTRY  *Entry2;
-  LIST_ENTRY  *Next;
-  IP6_INTERFACE   *IpIf;
-  IP6_DAD_ENTRY   *DadEntry;
-  IP6_DELAY_JOIN_LIST   *DelayNode;
+  LIST_ENTRY  *Entry;
+  LIST_ENTRY  *Entry2;
+  LIST_ENTRY  *Next;
+  IP6_INTERFACE   *IpIf;
+  IP6_DAD_ENTRY   *DadEntry;
+  IP6_DELAY_JOIN_LIST *DelayNode;
+  IP6_ADDRESS_INFO*AddrInfo;
+  IP6_PROTOCOL*Instance;
+  BOOLEAN Recovery;
+
+  Recovery = FALSE;
   
   //
   // Currently there are only two policies: Manual and Automatic. Regardless of
   // what transition is going on, i.e., Manual -> Automatic and Automatic ->
   // Manual, we have to free default router list, on-link prefix list, 
autonomous
@@ -78,22 +83,52 @@ Ip6ConfigOnPolicyChanged (
   IP6_LINK_LOCAL_PREFIX_LENGTH,
   &IpSb->LinkLocalAddr
   );
   }
 
-  //
-  // All IPv6 children that use global unicast address as it's source address
-  // should be destryoed now. The survivers are those use the link-local 
address
-  // or the unspecified address as the source address.
-  // TODO: Conduct a check here.
-  Ip6RemoveAddr (
-IpSb,
-&IpSb->DefaultInterface->AddressList,
-&IpSb->DefaultInterface->AddressCount,
-NULL,
-0
-);
+  if (!IsListEmpty (&IpSb->DefaultInterface->AddressList) && 
IpSb->DefaultInterface->AddressCount > 0) {
+//  
+// If any IPv6 children (Instance) in configured state and use global 
unicast address, it will be 
+// destroyed in Ip6RemoveAddr() function later. Then, the upper layer 
driver's Stop() function will be 
+// called, which may break the upper layer network stacks. So, the driver 
should take the responsibility 
+// for the recovery by using ConnectController() after Ip6RemoveAddr(). 
+// Here, just check whether need to recover the upper layer network stacks 
later.
+//
+NET_LIST_FOR_EACH (Entry, &IpSb->DefaultInterface->AddressList) { 
+  AddrInfo = NET_LIST_USER_STRUCT_S (Entry, IP6_ADDRESS_INFO, Link, 
IP6_ADDR_INFO_SIGNATURE);
+  if (!IsListEmpty (&IpSb->Children)) {
+NET_LIST_FOR_EACH (Entry2, &IpSb->Children) {
+  Instance = NET_LIST_USER_STRUCT_S (Entry2, IP6_PROTOCOL, Link, 
IP6_PROTOCOL_SIGNATURE);
+  if ((Instance->State == IP6_STATE_CONFIGED) && EFI_IP6_EQUAL 
(&Instance->ConfigData.StationAddress, &AddrInfo->Address)) {
+Recovery = TRUE;
+break;
+  }
+}
+  }
+}
+
+//
+// All IPv6 children that use global unicast address as it's source address
+// should be destroyed now. The survivers are those use the link-local 
address
+// or the unspecified address as the source address.
+// TODO: Conduct a check here.
+Ip6RemoveAddr (
+  IpSb,
+  &IpSb->DefaultInterface->AddressList,
+  &IpSb->DefaultInterface->AddressCount,
+  NULL,
+  0
+  );
+
+if (IpSb->Controller != NULL && Recovery) {
+  //
+  // ConnectController() to recover the upper layer network stacks.
+  //
+  gBS->ConnectController (IpSb->Controller, NULL, NULL, TRUE);
+}
+  }
+
 
   NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) {
 //
 // remove all pending delay node and DAD entries for the global addresses.
 //
@@ -128,11 +163,10 @@ Ip6ConfigOnPolicyChanged (
 //
 // delay 1 second
 //
 IpSb->Ticks   = (UINT32) IP6_GET_TICKS 
(IP6_ONE_SECOND_IN_MS);
   }
-
 }
 
 /**
   The work function to trigger the DHCPv6 process to perform a stateful 
autoconfiguration.
 
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 2/2] NetworkPkg/HttpDxe: Destroy the TLS instance when cleaning up the HTTP child

2017-07-30 Thread Jiaxin Wu
During clean up the HTTP child, all resources used by it should be cleaned. But
currently, TLS instance is not destroyed.

This patch is to fix this issue.

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/HttpDxe/HttpImpl.c |  1 +
 NetworkPkg/HttpDxe/HttpProto.c|  7 +++
 NetworkPkg/HttpDxe/HttpProto.h|  3 ++-
 NetworkPkg/HttpDxe/HttpsSupport.c | 14 +++---
 NetworkPkg/HttpDxe/HttpsSupport.h |  4 +++-
 5 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
index 1f7a4fa..9570053 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.c
+++ b/NetworkPkg/HttpDxe/HttpImpl.c
@@ -378,10 +378,11 @@ EfiHttpRequest (
 ImageHandle = HttpInstance->Service->Ip4DriverBindingHandle;
   }
 
   HttpInstance->TlsChildHandle = TlsCreateChild (
ImageHandle,
+   &(HttpInstance->TlsSb),
&(HttpInstance->Tls),
&(HttpInstance->TlsConfiguration)
);
   if (HttpInstance->TlsChildHandle == NULL) {
 return EFI_DEVICE_ERROR;
diff --git a/NetworkPkg/HttpDxe/HttpProto.c b/NetworkPkg/HttpDxe/HttpProto.c
index 3fda294..ab00f3d 100644
--- a/NetworkPkg/HttpDxe/HttpProto.c
+++ b/NetworkPkg/HttpDxe/HttpProto.c
@@ -862,10 +862,17 @@ HttpCleanProtocol (
   }
   
   NetMapClean (&HttpInstance->TxTokens);
   NetMapClean (&HttpInstance->RxTokens);
 
+  if (HttpInstance->TlsSb != NULL && HttpInstance->TlsChildHandle != NULL) {
+//
+// Destroy the TLS instance.   
+//
+HttpInstance->TlsSb->DestroyChild (HttpInstance->TlsSb, 
HttpInstance->TlsChildHandle);
+  }
+
   if (HttpInstance->Tcp4ChildHandle != NULL) {
 gBS->CloseProtocol (
HttpInstance->Tcp4ChildHandle,
&gEfiTcp4ProtocolGuid,
HttpInstance->Service->Ip4DriverBindingHandle,
diff --git a/NetworkPkg/HttpDxe/HttpProto.h b/NetworkPkg/HttpDxe/HttpProto.h
index 95fb484..04d36aa 100644
--- a/NetworkPkg/HttpDxe/HttpProto.h
+++ b/NetworkPkg/HttpDxe/HttpProto.h
@@ -164,11 +164,12 @@ typedef struct _HTTP_PROTOCOL {
 
   //
   // Https Support
   //
   BOOLEAN  UseHttps;
-  
+
+  EFI_SERVICE_BINDING_PROTOCOL *TlsSb;
   EFI_HANDLE   TlsChildHandle; /// Tls ChildHandle
   TLS_CONFIG_DATA  TlsConfigData;
   EFI_TLS_PROTOCOL *Tls;
   EFI_TLS_CONFIGURATION_PROTOCOL   *TlsConfiguration;
   EFI_TLS_SESSION_STATETlsSessionState;
diff --git a/NetworkPkg/HttpDxe/HttpsSupport.c 
b/NetworkPkg/HttpDxe/HttpsSupport.c
index e4d9a37..e6f4d5a 100644
--- a/NetworkPkg/HttpDxe/HttpsSupport.c
+++ b/NetworkPkg/HttpDxe/HttpsSupport.c
@@ -138,44 +138,44 @@ IsHttpsUrl (
 
 /**
   Creates a Tls child handle, open EFI_TLS_PROTOCOL and 
EFI_TLS_CONFIGURATION_PROTOCOL.
 
   @param[in]  ImageHandle   The firmware allocated handle for the UEFI 
image.
+  @param[out] TlsSb Pointer to the TLS 
SERVICE_BINDING_PROTOCOL.
   @param[out] TlsProto  Pointer to the EFI_TLS_PROTOCOL instance.
   @param[out] TlsConfiguration  Pointer to the 
EFI_TLS_CONFIGURATION_PROTOCOL instance.
 
   @return  The child handle with opened EFI_TLS_PROTOCOL and 
EFI_TLS_CONFIGURATION_PROTOCOL.
 
 **/
 EFI_HANDLE
 EFIAPI
 TlsCreateChild (
   IN  EFI_HANDLE ImageHandle,
+  OUT EFI_SERVICE_BINDING_PROTOCOL   **TlsSb,
   OUT EFI_TLS_PROTOCOL   **TlsProto,
   OUT EFI_TLS_CONFIGURATION_PROTOCOL **TlsConfiguration
   )
 {
   EFI_STATUSStatus;
-  EFI_SERVICE_BINDING_PROTOCOL  *TlsSb;
   EFI_HANDLETlsChildHandle;
 
-  TlsSb  = NULL;
   TlsChildHandle = 0;
 
   //
   // Locate TlsServiceBinding protocol.
   //
   gBS->LocateProtocol (
  &gEfiTlsServiceBindingProtocolGuid,
  NULL,
- (VOID **) &TlsSb
+ (VOID **) TlsSb
  );
-  if (TlsSb == NULL) {
+  if (*TlsSb == NULL) {
 return NULL;
   }
 
-  Status = TlsSb->CreateChild (TlsSb, &TlsChildHandle);
+  Status = (*TlsSb)->CreateChild (*TlsSb, &TlsChildHandle);
   if (EFI_ERROR (Status)) {
 return NULL;
   }
 
   Status = gBS->OpenProtocol (
@@ -185,11 +185,11 @@ TlsCreateChild (
   ImageHandle,
   TlsChildHandle,
   EFI_OPEN_PROTOCOL_GET_PROTOCOL
   );
   if (EFI_ERROR (Status)) {
-TlsSb->DestroyChild (TlsSb, TlsChildHandle);
+(*TlsSb)->DestroyChild (*TlsSb, TlsChildHandle);
 return NULL;
   }
 
   Status = gBS->OpenProtocol (
   TlsChildHandle,
@@ -198,11 +198,11 @@ TlsCreateChild (
   ImageHandle,
   TlsChildHandle,
   EFI_OPEN_PROTOCOL_GET_PROTOCOL
   );
   if (EFI_ERROR (Status)) {
-TlsSb->DestroyChild (

[edk2] [Patch 0/2] Fix the bug when cleaning up the TLS instance

2017-07-30 Thread Jiaxin Wu
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Long Qin 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 

Jiaxin Wu (2):
  CryptoPkg/TlsLib: Remove the redundant free of BIO objects
  NetworkPkg/HttpDxe: Destroy the TLS instance when cleaning up the HTTP child

 CryptoPkg/Library/TlsLib/TlsInit.c | 10 +-
 NetworkPkg/HttpDxe/HttpImpl.c  |  1 +
 NetworkPkg/HttpDxe/HttpProto.c |  7 +++
 NetworkPkg/HttpDxe/HttpProto.h |  3 ++-
 NetworkPkg/HttpDxe/HttpsSupport.c  | 14 +++---
 NetworkPkg/HttpDxe/HttpsSupport.h  |  4 +++-
 6 files changed, 21 insertions(+), 18 deletions(-)

-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 1/2] CryptoPkg/TlsLib: Remove the redundant free of BIO objects

2017-07-30 Thread Jiaxin Wu
TLS BIO objects (InBio/OutBio) will be freed by SSL_free() function.
So, the following free operation (BIO_free) in TlsFree is redundant.
It can be removed directly.

Cc: Ye Ting 
Cc: Long Qin 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 CryptoPkg/Library/TlsLib/TlsInit.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/CryptoPkg/Library/TlsLib/TlsInit.c 
b/CryptoPkg/Library/TlsLib/TlsInit.c
index e2c9744..e524647 100644
--- a/CryptoPkg/Library/TlsLib/TlsInit.c
+++ b/CryptoPkg/Library/TlsLib/TlsInit.c
@@ -128,24 +128,16 @@ TlsFree (
   if (TlsConn == NULL) {
 return;
   }
 
   //
-  // Free the internal TLS and BIO objects.
+  // Free the internal TLS and related BIO objects.
   //
   if (TlsConn->Ssl != NULL) {
 SSL_free (TlsConn->Ssl);
   }
 
-  if (TlsConn->InBio != NULL) {
-BIO_free (TlsConn->InBio);
-  }
-
-  if (TlsConn->OutBio != NULL) {
-BIO_free (TlsConn->OutBio);
-  }
-
   OPENSSL_free (Tls);
 }
 
 /**
   Create a new TLS object for a connection.
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] NetworkPkg/HttpDxe: Support HTTP Patch method

2017-08-02 Thread Jiaxin Wu
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/HttpDxe/HttpImpl.c | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
index 8a9e573..e0fecac 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.c
+++ b/NetworkPkg/HttpDxe/HttpImpl.c
@@ -274,14 +274,15 @@ EfiHttpRequest (
   }
 
   Request = HttpMsg->Data.Request;
 
   //
-  // Only support GET, HEAD, PUT and POST method in current implementation.
+  // Only support GET, HEAD, PATCH, PUT and POST method in current 
implementation.
   //
   if ((Request != NULL) && (Request->Method != HttpMethodGet) &&
-  (Request->Method != HttpMethodHead) && (Request->Method != 
HttpMethodPut) && (Request->Method != HttpMethodPost)) {
+  (Request->Method != HttpMethodHead) && (Request->Method != 
HttpMethodPut) && 
+  (Request->Method != HttpMethodPost) && (Request->Method != 
HttpMethodPatch)) {
 return EFI_UNSUPPORTED;
   }
 
   HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (This);
   ASSERT (HttpInstance != NULL);
@@ -297,18 +298,20 @@ EfiHttpRequest (
 return EFI_NOT_STARTED;
   }
 
   if (Request == NULL) {
 //
-// Request would be NULL only for PUT/POST operation (in the current 
implementation)
+// Request would be NULL only for PUT/POST/PATCH operation (in the current 
implementation)
 //
-if ((HttpInstance->Method != HttpMethodPut) && (HttpInstance->Method != 
HttpMethodPost)) {
+if ((HttpInstance->Method != HttpMethodPut) && 
+(HttpInstance->Method != HttpMethodPost) && 
+(HttpInstance->Method != HttpMethodPatch)) {
   return EFI_INVALID_PARAMETER;
 }
 
 //
-// For PUT/POST, we need to have the TCP already configured. Bail out if 
it is not!
+// For PUT/POST/PATCH, we need to have the TCP already configured. Bail 
out if it is not!
 //
 if (HttpInstance->State < HTTP_STATE_TCP_CONFIGED) {
   return EFI_INVALID_PARAMETER;
 }
 
@@ -615,11 +618,11 @@ EfiHttpRequest (
 
   ASSERT (RequestMsg != NULL);
 
   //
   // Every request we insert a TxToken and a response call would remove the 
TxToken.
-  // In cases of PUT/POST, after an initial request-response pair, we would do 
a
+  // In cases of PUT/POST/PATCH, after an initial request-response pair, we 
would do a
   // continuous request without a response call. So, in such cases, where 
Request
   // structure is NULL, we would not insert a TxToken.
   //
   if (Request != NULL) {
 Status = NetMapInsertTail (&HttpInstance->TxTokens, Token, Wrap);
@@ -,11 +1114,11 @@ HttpResponseWorker (
 
 Status = EFI_NOT_READY;
 ValueInItem = NULL;
 
 //
-// In cases of PUT/POST, after an initial request-response pair, we would 
do a
+// In cases of PUT/POST/PATCH, after an initial request-response pair, we 
would do a
 // continuous request without a response call. So, we would not do an 
insert of
 // TxToken. After we have sent the complete file, we will call a response 
to get
 // a final response from server. In such a case, we would not have any 
TxTokens.
 // Hence, check that case before doing a NetMapRemoveHead.
 //
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v3][Patch 2/4] MdePkg/UefiDevicePathLib: Add DevPathFromTextDns and DevPathToTextDns libraries

2017-08-03 Thread Jiaxin Wu
V3:
* Fix the bug in DevPathFromTextDns()

V2:
* Add no IP instance case check.

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
Reviewed-by: Fu Siyuan 
---
 .../Library/UefiDevicePathLib/DevicePathFromText.c | 90 ++
 .../Library/UefiDevicePathLib/DevicePathToText.c   | 46 +++
 2 files changed, 136 insertions(+)

diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c 
b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
index f50c11c..0fb703b 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
@@ -2723,10 +2723,99 @@ DevPathFromTextBluetoothLE (
 );
   return (EFI_DEVICE_PATH_PROTOCOL *) BluetoothLeDp;
 }
 
 /**
+  Converts a text device path node to DNS device path structure.
+
+  @param TextDeviceNode  The input Text device path node.
+
+  @return A pointer to the newly-created DNS device path structure.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextDns (
+  IN CHAR16 *TextDeviceNode
+  )
+{
+  CHAR16*DeviceNodeStr;
+  CHAR16*DeviceNodeStrPtr;
+  UINT32DnsServerIpCount;
+  UINT16DnsDeviceNodeLength;
+  DNS_DEVICE_PATH   *DnsDeviceNode;
+  UINT32DnsServerIpIndex;
+  CHAR16*DnsServerIp;
+
+
+  //
+  // Count the DNS server address number.
+  //
+  DeviceNodeStr = UefiDevicePathLibStrDuplicate (TextDeviceNode);
+  if (DeviceNodeStr == NULL) {
+return NULL;
+  }
+
+  DeviceNodeStrPtr = DeviceNodeStr;
+  
+  DnsServerIpCount = 0;
+  while (DeviceNodeStrPtr != NULL && *DeviceNodeStrPtr != L'\0') {
+GetNextParamStr (&DeviceNodeStrPtr);
+DnsServerIpCount ++; 
+  }
+
+  FreePool (DeviceNodeStr);
+  DeviceNodeStr = NULL;
+
+  //
+  // One or more instances of the DNS server address in EFI_IP_ADDRESS, 
+  // otherwise, NULL will be returned.
+  //
+  if (DnsServerIpCount == 0) {
+return NULL;
+  }
+
+  //
+  // Create the DNS DeviceNode.
+  //
+  DnsDeviceNodeLength = (UINT16) (sizeof (EFI_DEVICE_PATH_PROTOCOL) + sizeof 
(UINT8) + DnsServerIpCount * sizeof (EFI_IP_ADDRESS));
+  DnsDeviceNode   = (DNS_DEVICE_PATH *) CreateDeviceNode (
+  MESSAGING_DEVICE_PATH,
+  MSG_DNS_DP,
+  DnsDeviceNodeLength
+  );
+
+  //
+  // Confirm the DNS server address is IPv4 or IPv6 type.
+  //
+  DeviceNodeStrPtr = TextDeviceNode;
+  while (!IS_NULL (*DeviceNodeStrPtr)) {
+if (*DeviceNodeStrPtr == L'.') {
+  DnsDeviceNode->IsIPv6 = 0x00;
+  break;
+}
+
+if (*DeviceNodeStrPtr == L':') {
+  DnsDeviceNode->IsIPv6 = 0x01;
+  break;
+}
+
+DeviceNodeStrPtr++;
+  }
+
+  for (DnsServerIpIndex = 0; DnsServerIpIndex < DnsServerIpCount; 
DnsServerIpIndex++) {
+DnsServerIp = GetNextParamStr (&TextDeviceNode);
+if (DnsDeviceNode->IsIPv6 == 0x00) {
+  StrToIpv4Address (DnsServerIp,  NULL, 
&(DnsDeviceNode->DnsServerIp[DnsServerIpIndex].v4), NULL);
+} else {
+  StrToIpv6Address (DnsServerIp, NULL, 
&(DnsDeviceNode->DnsServerIp[DnsServerIpIndex].v6), NULL);
+}
+  }
+  
+  return (EFI_DEVICE_PATH_PROTOCOL *) DnsDeviceNode;
+}
+
+/**
   Converts a text device path node to URI device path structure.
 
   @param TextDeviceNode  The input Text device path node.
 
   @return A pointer to the newly-created URI device path structure.
@@ -3395,10 +3484,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED 
DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevP
   {L"UsbTestAndMeasurement",   DevPathFromTextUsbTestAndMeasurement   },
   {L"UsbWwid", DevPathFromTextUsbWwid },
   {L"Unit",DevPathFromTextUnit},
   {L"iSCSI",   DevPathFromTextiSCSI   },
   {L"Vlan",DevPathFromTextVlan},
+  {L"Dns", DevPathFromTextDns },
   {L"Uri", DevPathFromTextUri },
   {L"Bluetooth",   DevPathFromTextBluetooth   },
   {L"Wi-Fi",   DevPathFromTextWiFi},
   {L"BluetoothLE", DevPathFromTextBluetoothLE },
   {L"MediaPath",   DevPathFromTextMediaPath   },
diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c 
b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
index b8d9491..63542db 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
@@ -1695,10 +1695,55 @@ DevPathToTextBluetoothLE (
 BluetoothLE->Address.Type
 );
 }
 
 /**
+  Converts a DNS device path structure to its string representative.
+
+  @param Str The string representative of input device.
+  @param DevPath 

[edk2] [Patch] NetworkPkg/HttpBootDxe: Refine the coding style.

2017-08-08 Thread Jiaxin Wu
Cc: Ye Ting 
Cc: Bi Dandan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/HttpBootDxe/HttpBootSupport.c | 2 +-
 NetworkPkg/HttpBootDxe/HttpBootSupport.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/NetworkPkg/HttpBootDxe/HttpBootSupport.c 
b/NetworkPkg/HttpBootDxe/HttpBootSupport.c
index 4e78cf3..d508e2c 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootSupport.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootSupport.c
@@ -1329,11 +1329,11 @@ HttpBootRegisterRamDisk (
 
 **/
 BOOLEAN
 HttpBootIsHttpRedirectStatusCode (
   IN   EFI_HTTP_STATUS_CODEStatusCode
- )
+  )
 {
   if (StatusCode == HTTP_STATUS_301_MOVED_PERMANENTLY ||
   StatusCode == HTTP_STATUS_302_FOUND ||
   StatusCode == HTTP_STATUS_307_TEMPORARY_REDIRECT ||
   StatusCode == HTTP_STATUS_308_PERMANENT_REDIRECT) {
diff --git a/NetworkPkg/HttpBootDxe/HttpBootSupport.h 
b/NetworkPkg/HttpBootDxe/HttpBootSupport.h
index c10b2cf..9b7acd9 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootSupport.h
+++ b/NetworkPkg/HttpBootDxe/HttpBootSupport.h
@@ -455,7 +455,7 @@ HttpBootRegisterRamDisk (
 
 **/
 BOOLEAN
 HttpBootIsHttpRedirectStatusCode (
   IN   EFI_HTTP_STATUS_CODEStatusCode
- );
+  );
 #endif
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] NetworkPkg/HttpDxe: Handle the HttpVersionUnsupported in the HttpConfigData

2017-08-08 Thread Jiaxin Wu
Cc: Ye Ting 
Cc: Jin Eric 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/HttpDxe/HttpImpl.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
index e0fecac..442397c 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.c
+++ b/NetworkPkg/HttpDxe/HttpImpl.c
@@ -149,10 +149,14 @@ EfiHttpConfigure (
   HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (This);
   ASSERT (HttpInstance != NULL && HttpInstance->Service != NULL);
 
   if (HttpConfigData != NULL) {
 
+if (HttpConfigData->HttpVersion == HttpVersionUnsupported) {
+  return EFI_UNSUPPORTED;
+}
+
 //
 // Now configure this HTTP instance.
 //
 if (HttpInstance->State != HTTP_STATE_UNCONFIGED) {
   return EFI_ALREADY_STARTED;
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch v2] NetworkPkg/HttpDxe: Handle the HttpVersionUnsupported in the HttpConfigData

2017-08-10 Thread Jiaxin Wu
v2:
* Refine the patch by changing the '==' to '>='.

Cc: Ye Ting 
Cc: Jin Eric 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/HttpDxe/HttpImpl.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
index e0fecac..c104b61 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.c
+++ b/NetworkPkg/HttpDxe/HttpImpl.c
@@ -149,10 +149,14 @@ EfiHttpConfigure (
   HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (This);
   ASSERT (HttpInstance != NULL && HttpInstance->Service != NULL);
 
   if (HttpConfigData != NULL) {
 
+if (HttpConfigData->HttpVersion >= HttpVersionUnsupported) {
+  return EFI_UNSUPPORTED;
+}
+
 //
 // Now configure this HTTP instance.
 //
 if (HttpInstance->State != HTTP_STATE_UNCONFIGED) {
   return EFI_ALREADY_STARTED;
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] NetworkPkg/Ip6Dxe: Fix the bug when checking the DataSize

2017-08-15 Thread Jiaxin Wu
During setting the DnsServer, the DataSize check is incorrect.
This patch is to fix the issue.

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c 
b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
index 61418e2..f4b9374 100644
--- a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
+++ b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
@@ -1464,11 +1464,11 @@ Ip6ConfigSetDnsServer (
   OldDns = NULL;
   NewDns = NULL;
   Item   = NULL;
   Tmp= NULL;
 
-  if ((DataSize == 0) && (DataSize % sizeof (EFI_IPv6_ADDRESS) != 0)) {
+  if ((DataSize != 0) && (DataSize % sizeof (EFI_IPv6_ADDRESS) != 0)) {
 return EFI_BAD_BUFFER_SIZE;
   }
 
   if (Instance->Policy != Ip6ConfigPolicyManual) {
 return EFI_WRITE_PROTECTED;
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] MdeModulePkg/Library: Remove the self-reference in UdpIoLib/TcpIoLib/IpIoLib

2017-08-17 Thread Jiaxin Wu
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Shao Ming 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf   | 3 +--
 MdeModulePkg/Library/DxeTcpIoLib/DxeTcpIoLib.inf | 3 +--
 MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf 
b/MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf
index f62a36f..086c74d 100644
--- a/MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf
+++ b/MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf
@@ -1,9 +1,9 @@
 ## @file
 #  This library instance provides IP services upon EFI IPv4/IPv6 Protocols.
 #
-#  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+#  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD 
License
 #  which accompanies this distribution.  The full text of the license may be 
found at
 #  http://opensource.org/licenses/bsd-license.php
 #
@@ -35,11 +35,10 @@
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
 
 
 [LibraryClasses]
-  IpIoLib
   BaseLib
   DebugLib
   UefiBootServicesTableLib
   MemoryAllocationLib
   BaseMemoryLib
diff --git a/MdeModulePkg/Library/DxeTcpIoLib/DxeTcpIoLib.inf 
b/MdeModulePkg/Library/DxeTcpIoLib/DxeTcpIoLib.inf
index 4f11c6f..1b29dce 100644
--- a/MdeModulePkg/Library/DxeTcpIoLib/DxeTcpIoLib.inf
+++ b/MdeModulePkg/Library/DxeTcpIoLib/DxeTcpIoLib.inf
@@ -1,9 +1,9 @@
 ## @file
 #  This library instance provides TCP services by EFI TCPv4/TCPv6 Protocols.
 #  
-#  Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
+#  Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD 
License
 #  which accompanies this distribution.  The full text of the license may be 
found at
 #  http://opensource.org/licenses/bsd-license.php
 #
@@ -35,11 +35,10 @@
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
 
 
 [LibraryClasses]
-  TcpIoLib
   BaseLib
   DebugLib
   UefiBootServicesTableLib
   MemoryAllocationLib
   BaseMemoryLib
diff --git a/MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf 
b/MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf
index a9683c9..ce6e996 100644
--- a/MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf
+++ b/MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf
@@ -1,9 +1,9 @@
 ## @file
 #  This library instance provides UDP services by consuming EFI UDPv4/UDPv6 
Protocols.
 #  
-#  Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.
+#  Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD 
License
 #  which accompanies this distribution.  The full text of the license may be 
found at
 #  http://opensource.org/licenses/bsd-license.php
 #
@@ -35,11 +35,10 @@
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
 
 
 [LibraryClasses]
-  UdpIoLib
   BaseLib
   DebugLib
   UefiBootServicesTableLib
   MemoryAllocationLib
   BaseMemoryLib
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] NetworkPkg/IScsiDxe: Fix the incorrect max length of IP_ADDRESS.

2017-08-31 Thread Jiaxin Wu
When creating the ISCSI string OpCode for IP_ADDRESS, the max length
should be IP(4)_STR_MAX_SIZE instead of IP(4)_MAX_SIZE.

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/IScsiDxe/IScsiMisc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMisc.c
index e20fe91..efd05cf 100644
--- a/NetworkPkg/IScsiDxe/IScsiMisc.c
+++ b/NetworkPkg/IScsiDxe/IScsiMisc.c
@@ -1007,11 +1007,11 @@ IScsiCreateKeywords (
   StringToken,
   StringToken,
   0,
   0,
   IP4_MIN_SIZE,
-  IP4_MAX_SIZE,
+  IP4_STR_MAX_SIZE,
   NULL
   );
 
 //
 // Create iSCSIInitiatorNetmask Keyword.
@@ -1033,11 +1033,11 @@ IScsiCreateKeywords (
   StringToken,
   StringToken,
   0,
   0,
   IP4_MIN_SIZE,
-  IP4_MAX_SIZE,
+  IP4_STR_MAX_SIZE,
   NULL
   );
 
 //
 // Create iSCSIInitiatorGateway Keyword.
@@ -1059,11 +1059,11 @@ IScsiCreateKeywords (
   StringToken,
   StringToken,
   0,
   0,
   IP4_MIN_SIZE,
-  IP4_MAX_SIZE,
+  IP4_STR_MAX_SIZE,
   NULL
   );
 
 //
 // Create iSCSITargetInfoViaDHCP Keyword.
@@ -1165,11 +1165,11 @@ IScsiCreateKeywords (
   StringToken,
   StringToken,
   0,
   0,
   IP_MIN_SIZE,
-  IP_MAX_SIZE,
+  IP_STR_MAX_SIZE,
   NULL
   );
 
 //
 // Create iSCSILUN Keyword.
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] NetworkPkg/HttpDxe: Support HTTP Delete Method.

2018-02-26 Thread Jiaxin Wu
Per the request to support HttpMethodDelete:
https://bugzilla.tianocore.org/show_bug.cgi?id=879,
This patch is to enable the HTTP Delete Method.

Cc: Karunakar P 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/HttpDxe/HttpImpl.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
index b3a64cf516..a2af59674a 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.c
+++ b/NetworkPkg/HttpDxe/HttpImpl.c
@@ -1,9 +1,9 @@
 /** @file
   Implementation of EFI_HTTP_PROTOCOL protocol interfaces.
 
-  Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
+  Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
   (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -279,15 +279,16 @@ EfiHttpRequest (
   }
 
   Request = HttpMsg->Data.Request;
 
   //
-  // Only support GET, HEAD, PATCH, PUT and POST method in current 
implementation.
+  // Only support GET, HEAD, DELETE, PATCH, PUT and POST method in current 
implementation.
   //
   if ((Request != NULL) && (Request->Method != HttpMethodGet) &&
-  (Request->Method != HttpMethodHead) && (Request->Method != 
HttpMethodPut) && 
-  (Request->Method != HttpMethodPost) && (Request->Method != 
HttpMethodPatch)) {
+  (Request->Method != HttpMethodHead) && (Request->Method != 
HttpMethodDelete) && 
+  (Request->Method != HttpMethodPut) && (Request->Method != 
HttpMethodPost) && 
+  (Request->Method != HttpMethodPatch)) {
 return EFI_UNSUPPORTED;
   }
 
   HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (This);
 
-- 
2.16.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] NetworkPkg/HttpBootDxe: Fix the incorrect error message output.

2018-02-28 Thread Jiaxin Wu
For IPv6 case, if one invalid URL returned from DHCP server, HttpBootDxe
driver could not retrieve the URL host address from DNS server. In such a
case, the error message should be printed as:
  Error: Could not retrieve the host address from DNS server.
Instead of:
  Error: Could not discover the boot information for DHCP server.
Then, we can still output as following:
  Error: Could not retrieve NBP file size from HTTP server.

Besides, currently implementation in HttpBootLoadFile will always output
error message even the HTTP process is correct.

This patch is to fix above issue.

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/HttpBootDxe/HttpBootClient.c |  1 +
 NetworkPkg/HttpBootDxe/HttpBootImpl.c   | 37 ++---
 2 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/NetworkPkg/HttpBootDxe/HttpBootClient.c 
b/NetworkPkg/HttpBootDxe/HttpBootClient.c
index b93e63bb2f..1d1e47008d 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootClient.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootClient.c
@@ -472,10 +472,11 @@ HttpBootDhcp6ExtractUriInfo (
 }
 
 Status = HttpBootDns (Private, HostNameStr, &IpAddr);
 FreePool (HostNameStr);
 if (EFI_ERROR (Status)) {
+  AsciiPrint ("\n  Error: Could not retrieve the host address from DNS 
server.\n");
   goto Error;
 }  
   } 
   
   CopyMem (&Private->ServerIp.v6, &IpAddr, sizeof (EFI_IPv6_ADDRESS));
diff --git a/NetworkPkg/HttpBootDxe/HttpBootImpl.c 
b/NetworkPkg/HttpBootDxe/HttpBootImpl.c
index 16c1207bf8..a0fd934ec4 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootImpl.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootImpl.c
@@ -1,9 +1,9 @@
 /** @file
   The implementation of EFI_LOAD_FILE_PROTOCOL for UEFI HTTP boot.
 
-Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 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.
  
@@ -329,11 +329,11 @@ HttpBootLoadFile (
 //
 // Parse the cached offer to get the boot file URL first.
 //
 Status = HttpBootDiscoverBootInfo (Private);
 if (EFI_ERROR (Status)) {
-  AsciiPrint ("\n  Error: Could not discover the boot information for DHCP 
server.\n");
+  AsciiPrint ("\n  Error: Could not retrieve NBP file size from HTTP 
server.\n");
   goto ON_EXIT;
 }
   }
 
   if (!Private->HttpCreated) {
@@ -398,26 +398,29 @@ HttpBootLoadFile (
  ImageType
  );
   
 ON_EXIT:
   HttpBootUninstallCallback (Private);
-
-  if (Status == EFI_ACCESS_DENIED) {
-AsciiPrint ("\n  Error: Could not establish connection with HTTP 
server.\n");
-  } else if (Status == EFI_BUFFER_TOO_SMALL && Buffer != NULL) {
-AsciiPrint ("\n  Error: Buffer size is smaller than the requested 
file.\n");
-  } else if (Status == EFI_OUT_OF_RESOURCES) {
-AsciiPrint ("\n  Error: Could not allocate I/O buffers.\n");
-  } else if (Status == EFI_DEVICE_ERROR) {
-AsciiPrint ("\n  Error: Network device error.\n");
-  } else if (Status == EFI_TIMEOUT) {
-AsciiPrint ("\n  Error: Server response timeout.\n");
-  } else if (Status == EFI_ABORTED) {
-AsciiPrint ("\n  Error: Remote boot cancelled.\n");
-  } else if (Status != EFI_BUFFER_TOO_SMALL) {
-AsciiPrint ("\n  Error: Unexpected network error.\n");
+  
+  if (EFI_ERROR (Status)) {
+if (Status == EFI_ACCESS_DENIED) {
+  AsciiPrint ("\n  Error: Could not establish connection with HTTP 
server.\n");
+} else if (Status == EFI_BUFFER_TOO_SMALL && Buffer != NULL) {
+  AsciiPrint ("\n  Error: Buffer size is smaller than the requested 
file.\n");
+} else if (Status == EFI_OUT_OF_RESOURCES) {
+  AsciiPrint ("\n  Error: Could not allocate I/O buffers.\n");
+} else if (Status == EFI_DEVICE_ERROR) {
+  AsciiPrint ("\n  Error: Network device error.\n");
+} else if (Status == EFI_TIMEOUT) {
+  AsciiPrint ("\n  Error: Server response timeout.\n");
+} else if (Status == EFI_ABORTED) {
+  AsciiPrint ("\n  Error: Remote boot cancelled.\n");
+} else if (Status != EFI_BUFFER_TOO_SMALL) {
+  AsciiPrint ("\n  Error: Unexpected network error.\n");
+}
   }
+  
   return Status;
 }
 
 /**
   Disable the use of UEFI HTTP boot function.
-- 
2.16.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] NetworkPkg/HttpBootDxe: Correct the parameter check for the usage of HttpBootGetFileFromCache.

2018-02-28 Thread Jiaxin Wu
The patch is to fix the incorrect parameter check for the 
HttpBootGetFileFromCache().

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/HttpBootDxe/HttpBootClient.c | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/NetworkPkg/HttpBootDxe/HttpBootClient.c 
b/NetworkPkg/HttpBootDxe/HttpBootClient.c
index 15e0ab9d69..b93e63bb2f 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootClient.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootClient.c
@@ -1,9 +1,9 @@
 /** @file
   Implementation of the boot file download function.
 
-Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 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.
  
@@ -434,11 +434,11 @@ HttpBootDhcp6ExtractUriInfo (
   goto Error;
 }
   }
   
   //
-  // Extract the HTTP server Ip frome URL. This is used to Check route table 
+  // Extract the HTTP server Ip from URL. This is used to Check route table 
   // whether can send message to HTTP Server Ip through the GateWay.
   //
   Status = HttpUrlGetIp6 (
  Private->BootFileUri,
  Private->BootFileUriParser,
@@ -744,23 +744,22 @@ HttpBootGetFileFromCache (
   LIST_ENTRY  *Entry2;
   HTTP_BOOT_CACHE_CONTENT *Cache;
   HTTP_BOOT_ENTITY_DATA   *EntityData;
   UINTN   CopyedSize;
   
-  if (Uri == NULL || BufferSize == 0 || Buffer == NULL || ImageType == NULL) {
+  if (Uri == NULL || BufferSize == NULL || Buffer == NULL || ImageType == 
NULL) {
 return EFI_INVALID_PARAMETER;
   }
 
   NET_LIST_FOR_EACH (Entry, &Private->CacheList) {
 Cache = NET_LIST_USER_STRUCT (Entry, HTTP_BOOT_CACHE_CONTENT, Link);
 //
 // Compare the URI to see whether we already have a cache for this file.
 //
 if ((Cache->RequestData != NULL) &&
 (Cache->RequestData->Url != NULL) &&
-(StrCmp (Uri, Cache->RequestData->Url) == 0)) 
-{
+(StrCmp (Uri, Cache->RequestData->Url) == 0)) {
   //
   // Hit in cache, record image type.
   //
   *ImageType  = Cache->ImageType;
 
@@ -945,11 +944,11 @@ HttpBootGetBootFile (
   Url = AllocatePool (UrlSize * sizeof (CHAR16));
   if (Url == NULL) {
 return EFI_OUT_OF_RESOURCES;
   }
   AsciiStrToUnicodeStrS (Private->BootFileUri, Url, UrlSize);
-  if (!HeaderOnly) {
+  if (!HeaderOnly && Buffer != NULL) {
 Status = HttpBootGetFileFromCache (Private, Url, BufferSize, Buffer, 
ImageType);
 if (Status != EFI_NOT_FOUND) {
   FreePool (Url);
   return Status;
 }
@@ -1127,11 +1126,11 @@ HttpBootGetBootFile (
   Context.Buffer = Buffer;
   Context.BufferSize = *BufferSize;
   Context.Cache  = Cache;
   Context.Private= Private;
   Status = HttpInitMsgParser (
- HeaderOnly? HttpMethodHead : HttpMethodGet,
+ HeaderOnly ? HttpMethodHead : HttpMethodGet,
  ResponseData->Response.StatusCode,
  ResponseData->HeaderCount,
  ResponseData->Headers,
  HttpBootGetBootFileCallback,
  (VOID*) &Context,
-- 
2.16.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] NetworkPkg/Udp6Dxe: Fix the failure to leave one multicast group address.

2018-03-01 Thread Jiaxin Wu
The issue was enrolled by the commit of ceec3638. One of the change in the 
commit
was to return the status from NetMapIterate in Udp6Groups function. But it 
should
not return EFI_ABORTED directly in case McastIp is not NULL, which means to 
terminate
the iteration and leave the McastIp successfully.

Cc: Wang Fan 
Cc: Fu Siyuan 
Cc: Ye Ting 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu 
---
 NetworkPkg/Udp6Dxe/Udp6Main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/NetworkPkg/Udp6Dxe/Udp6Main.c b/NetworkPkg/Udp6Dxe/Udp6Main.c
index 1d7f0acbc7..e9d94dd00c 100644
--- a/NetworkPkg/Udp6Dxe/Udp6Main.c
+++ b/NetworkPkg/Udp6Dxe/Udp6Main.c
@@ -380,10 +380,13 @@ Udp6Groups (
 
 Status = NetMapInsertTail (&Instance->McastIps, (VOID *) McastIp, NULL);
   } else {
 
 Status = NetMapIterate (&Instance->McastIps, Udp6LeaveGroup, 
MulticastAddress);
+if ((MulticastAddress != NULL) && (Status == EFI_ABORTED)) {
+  Status = EFI_SUCCESS;
+} 
   }
 
 ON_EXIT:
 
   gBS->RestoreTPL (OldTpl);
-- 
2.16.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] MdeModulePkg/Mtftp4Dxe: Restore the TPL before the poll function.

2018-03-01 Thread Jiaxin Wu
This patch is to fix the hang issue, which was enrolled by the commit of 
39b0867d.
The TPL should be restored before calling poll function at TPL_CALLBACK.

Cc: Wang Fan 
Cc: Fu Siyuan 
Cc: Ye Ting 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu 
---
 MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c 
b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c
index f5f9e6d8f7..64e0463dd9 100644
--- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c
+++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c
@@ -507,24 +507,27 @@ Mtftp4Start (
   if (EFI_ERROR (Status)) {
 Status = EFI_DEVICE_ERROR;
 goto ON_ERROR;
   }
 
+  //
+  // Restore the TPL now, don't call poll function at TPL_CALLBACK.
+  //
+  gBS->RestoreTPL (OldTpl);
+
   if (Token->Event != NULL) {
-gBS->RestoreTPL (OldTpl);
 return EFI_SUCCESS;
   }
 
   //
   // Return immediately for asynchronous operation or poll the
   // instance for synchronous operation.
   //
   while (Token->Status == EFI_NOT_READY) {
 This->Poll (This);
   }
-
-  gBS->RestoreTPL (OldTpl);
+  
   return Token->Status;
 
 ON_ERROR:
   Mtftp4CleanOperation (Instance, Status);
   gBS->RestoreTPL (OldTpl);
-- 
2.16.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] MdeModulePkg/Mtftp4Dxe: Separate the timer ticking to calculate the packet live time.

2018-03-01 Thread Jiaxin Wu
From: Fu Siyuan 

TPL deadlock issue was enrolled by the commit of 39b0867d. To resolve the issue,
this patch separated the timer ticking for all the MTFTP clients to calculate 
the
packet live time in TPL_NOTIFY level.

Cc: Wang Fan 
Cc: Fu Siyuan 
Cc: Ye Ting 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan 
Signed-off-by: Jiaxin Wu 
---
 .../Universal/Network/Mtftp4Dxe/Mtftp4Driver.c | 34 ++---
 .../Universal/Network/Mtftp4Dxe/Mtftp4Impl.c   |  5 +-
 .../Universal/Network/Mtftp4Dxe/Mtftp4Impl.h   |  6 ++-
 .../Universal/Network/Mtftp4Dxe/Mtftp4Support.c| 57 +-
 .../Universal/Network/Mtftp4Dxe/Mtftp4Support.h| 16 +-
 5 files changed, 97 insertions(+), 21 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Driver.c 
b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Driver.c
index a23d405baa..713cc66dd1 100644
--- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Driver.c
+++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Driver.c
@@ -1,9 +1,9 @@
 /** @file
   Implementation of Mtftp drivers.
 
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -160,15 +160,16 @@ Mtftp4CreateService (
   MtftpSb->Signature  = MTFTP4_SERVICE_SIGNATURE;
   MtftpSb->ServiceBinding = gMtftp4ServiceBindingTemplete;
   MtftpSb->ChildrenNum= 0;
   InitializeListHead (&MtftpSb->Children);
 
-  MtftpSb->Timer  = NULL;
-  MtftpSb->TimerToGetMap  = NULL;
-  MtftpSb->Controller = Controller;
-  MtftpSb->Image  = Image;
-  MtftpSb->ConnectUdp = NULL;
+  MtftpSb->Timer= NULL;
+  MtftpSb->TimerNotifyLevel = NULL;
+  MtftpSb->TimerToGetMap= NULL;
+  MtftpSb->Controller   = Controller;
+  MtftpSb->Image= Image;
+  MtftpSb->ConnectUdp   = NULL;
 
   //
   // Create the timer and a udp to be notified when UDP is uninstalled
   //
   Status = gBS->CreateEvent (
@@ -176,12 +177,24 @@ Mtftp4CreateService (
   TPL_CALLBACK,
   Mtftp4OnTimerTick,
   MtftpSb,
   &MtftpSb->Timer
   );
+  if (EFI_ERROR (Status)) {
+FreePool (MtftpSb);
+return Status;
+  }
 
+  Status = gBS->CreateEvent (
+  EVT_NOTIFY_SIGNAL | EVT_TIMER,
+  TPL_NOTIFY,
+  Mtftp4OnTimerTickNotifyLevel,
+  MtftpSb,
+  &MtftpSb->TimerNotifyLevel
+  );
   if (EFI_ERROR (Status)) {
+gBS->CloseEvent (MtftpSb->Timer);
 FreePool (MtftpSb);
 return Status;
   }
 
   //
@@ -194,10 +207,11 @@ Mtftp4CreateService (
   NULL,
   NULL,
   &MtftpSb->TimerToGetMap
   );
   if (EFI_ERROR (Status)) {
+gBS->CloseEvent (MtftpSb->TimerNotifyLevel);
 gBS->CloseEvent (MtftpSb->Timer);
 FreePool (MtftpSb);
 return Status;
   }
 
@@ -209,10 +223,11 @@ Mtftp4CreateService (
   NULL
   );
 
   if (MtftpSb->ConnectUdp == NULL) {
 gBS->CloseEvent (MtftpSb->TimerToGetMap);
+gBS->CloseEvent (MtftpSb->TimerNotifyLevel);
 gBS->CloseEvent (MtftpSb->Timer);
 FreePool (MtftpSb);
 return EFI_DEVICE_ERROR;
   }
 
@@ -232,10 +247,11 @@ Mtftp4CleanService (
   IN MTFTP4_SERVICE *MtftpSb
   )
 {
   UdpIoFreeIo (MtftpSb->ConnectUdp);
   gBS->CloseEvent (MtftpSb->TimerToGetMap);
+  gBS->CloseEvent (MtftpSb->TimerNotifyLevel);
   gBS->CloseEvent (MtftpSb->Timer);
 }
 
 
 /**
@@ -292,10 +308,16 @@ Mtftp4DriverBindingStart (
 
   if (EFI_ERROR (Status)) {
 goto ON_ERROR;
   }
 
+  Status = gBS->SetTimer (MtftpSb->TimerNotifyLevel, TimerPeriodic, 
TICKS_PER_SECOND);
+
+  if (EFI_ERROR (Status)) {
+goto ON_ERROR;
+  }
+  
   //
   // Install the Mtftp4ServiceBinding Protocol onto Controller
   //
   Status = gBS->InstallMultipleProtocolInterfaces (
   &Controller,
diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c 
b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c
index f5f9e6d8f7..d8c48ec8b2 100644
--- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c
+++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c
@@ -1080,10 +1080,11 @@ EfiMtftp4Poll (
   IN EFI_MTFTP4_PROTOCOL*This
   )
 {
   MTFTP4_PROTOCOL   *Instance;
   EFI_UDP4_PROTOCOL *Udp;
+  EFI_STATUSStatus;
 
   if (This == NULL) {
 return EFI_INVALID_PARAMETER;
   }
 
@@

[edk2] [Patch] MdeModulePkg/Mtftp4Dxe: Fix the incorrect return status.

2018-03-11 Thread Jiaxin Wu
The incorrect return status was caused by the commit of 39b0867d, which
was to resolve the token status error that does not compliance with spec
definition, but it results the protocol status not compliance with spec
definition.

This patch is to resolve above issue.

Cc: Wang Fan 
Cc: Fu Siyuan 
Cc: Ye Ting 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu 
---
 .../Universal/Network/Mtftp4Dxe/Mtftp4Impl.c   | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c 
b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c
index d8c48ec8b2..065528c937 100644
--- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c
+++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c
@@ -364,10 +364,11 @@ Mtftp4Start (
   MTFTP4_PROTOCOL   *Instance;
   EFI_MTFTP4_OVERRIDE_DATA  *Override;
   EFI_MTFTP4_CONFIG_DATA*Config;
   EFI_TPL   OldTpl;
   EFI_STATUSStatus;
+  EFI_STATUSTokenStatus;
 
   //
   // Validate the parameters
   //
   if ((This == NULL) || (Token == NULL) || (Token->Filename == NULL) ||
@@ -391,28 +392,28 @@ Mtftp4Start (
 return EFI_INVALID_PARAMETER;
   }
 
   Instance = MTFTP4_PROTOCOL_FROM_THIS (This);
 
-  Status = EFI_SUCCESS;
+  Status  = EFI_SUCCESS;
+  TokenStatus = EFI_SUCCESS;
+  
   OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
 
   if (Instance->State != MTFTP4_STATE_CONFIGED) {
 Status = EFI_NOT_STARTED;
   }
 
   if (Instance->Operation != 0) {
 Status = EFI_ACCESS_DENIED;
   }
 
-  if (EFI_ERROR (Status)) {
-gBS->RestoreTPL (OldTpl);
-return Status;
-  }
-
   if ((Token->OverrideData != NULL) && !Mtftp4OverrideValid (Instance, 
Token->OverrideData)) {
 Status = EFI_INVALID_PARAMETER;
+  }
+
+  if (EFI_ERROR (Status)) {
 gBS->RestoreTPL (OldTpl);
 return Status;
   }
 
   //
@@ -429,11 +430,11 @@ Mtftp4Start (
TRUE,
&Instance->RequestOption
);
 
 if (EFI_ERROR (Status)) {
-  Status = EFI_DEVICE_ERROR;
+  TokenStatus = EFI_DEVICE_ERROR;
   goto ON_ERROR;
 }
   }
 
   //
@@ -482,13 +483,12 @@ Mtftp4Start (
 
   //
   // Config the unicast UDP child to send initial request
   //
   Status = Mtftp4ConfigUnicastPort (Instance->UnicastPort, Instance);
-
   if (EFI_ERROR (Status)) {
-Status = EFI_DEVICE_ERROR;
+TokenStatus = EFI_DEVICE_ERROR;
 goto ON_ERROR;
   }
 
   //
   // Set initial status.
@@ -503,11 +503,11 @@ Mtftp4Start (
   } else {
 Status = Mtftp4RrqStart (Instance, Operation);
   }
 
   if (EFI_ERROR (Status)) {
-Status = EFI_DEVICE_ERROR;
+TokenStatus = EFI_DEVICE_ERROR;
 goto ON_ERROR;
   }
 
   if (Token->Event != NULL) {
 gBS->RestoreTPL (OldTpl);
@@ -524,11 +524,11 @@ Mtftp4Start (
 
   gBS->RestoreTPL (OldTpl);
   return Token->Status;
 
 ON_ERROR:
-  Mtftp4CleanOperation (Instance, Status);
+  Mtftp4CleanOperation (Instance, TokenStatus);
   gBS->RestoreTPL (OldTpl);
 
   return Status;
 }
 
-- 
2.16.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 1/2] NetworkPkg/IScsiDxe: Fix the ISCSI connection failure in certain case.

2018-03-12 Thread Jiaxin Wu
The ISCSI connection will fail for the first time if the target info is
retrieved from DHCP and expressed as URI format. The issue is caused by
the missing DNS protocol dependency check during the driver support
function.

This patch is to fix the above issue.

Cc: Fu Siyuan 
Cc: Ye Ting 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu 
---
 NetworkPkg/IScsiDxe/IScsiMisc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMisc.c
index 94f3725866..745b7ac07b 100644
--- a/NetworkPkg/IScsiDxe/IScsiMisc.c
+++ b/NetworkPkg/IScsiDxe/IScsiMisc.c
@@ -1982,11 +1982,11 @@ IScsiDnsIsConfigured (
 if (AttemptTmp->SessionConfigData.Enabled == ISCSI_DISABLED || StrCmp 
(MacString, AttemptMacString)) {
   FreePool (AttemptTmp);
   continue;
 }
 
-if (AttemptTmp->SessionConfigData.DnsMode) {
+if (AttemptTmp->SessionConfigData.DnsMode || 
AttemptTmp->SessionConfigData.TargetInfoFromDhcp) {
   FreePool (AttemptTmp);
   FreePool (AttemptConfigOrder);
   return TRUE;
 } else {
   FreePool (AttemptTmp);
-- 
2.16.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 2/3] NetworkPkg/TlsDxe: Handle the multiple TLS record messages encryption/decryption.

2018-03-19 Thread Jiaxin Wu
Cc: Karunakar P 
Cc: Fu Siyuan 
Cc: Ye Ting 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu 
---
 NetworkPkg/TlsDxe/TlsImpl.c | 74 +++--
 NetworkPkg/TlsDxe/TlsImpl.h |  6 +---
 2 files changed, 52 insertions(+), 28 deletions(-)

diff --git a/NetworkPkg/TlsDxe/TlsImpl.c b/NetworkPkg/TlsDxe/TlsImpl.c
index 8e1238216b..a026075f36 100644
--- a/NetworkPkg/TlsDxe/TlsImpl.c
+++ b/NetworkPkg/TlsDxe/TlsImpl.c
@@ -1,9 +1,9 @@
 /** @file
   The Miscellaneous Routines for TlsDxe driver.
 
-Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
 
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
@@ -48,10 +48,11 @@ TlsEncryptPacket (
   UINT16  ThisPlainMessageSize;
   TLS_RECORD_HEADER   *TempRecordHeader;
   UINT16  ThisMessageSize;
   UINT32  BufferOutSize;
   UINT8   *BufferOut;
+  UINT32  RecordCount;
   INTNRet;
 
   Status   = EFI_SUCCESS;
   BytesCopied  = 0;
   BufferInSize = 0;
@@ -59,10 +60,11 @@ TlsEncryptPacket (
   BufferInPtr  = NULL;
   RecordHeaderIn   = NULL;
   TempRecordHeader = NULL;
   BufferOutSize= 0;
   BufferOut= NULL;
+  RecordCount  = 0;
   Ret  = 0;
 
   //
   // Calculate the size according to the fragment table.
   //
@@ -89,34 +91,46 @@ TlsEncryptPacket (
   (*FragmentTable)[Index].FragmentLength
   );
 BytesCopied += (*FragmentTable)[Index].FragmentLength;
   }
 
-  BufferOut = AllocateZeroPool (MAX_BUFFER_SIZE);
+  //
+  // Count TLS record number.
+  //
+  BufferInPtr = BufferIn;
+  while ((UINTN) BufferInPtr < (UINTN) BufferIn + BufferInSize) {
+RecordHeaderIn = (TLS_RECORD_HEADER *) BufferInPtr;
+if (RecordHeaderIn->ContentType != TlsContentTypeApplicationData || 
RecordHeaderIn->Length > TLS_PLAINTEXT_RECORD_MAX_PAYLOAD_LENGTH) {
+  Status = EFI_INVALID_PARAMETER;
+  goto ERROR;
+}
+BufferInPtr += TLS_RECORD_HEADER_LENGTH + RecordHeaderIn->Length;
+RecordCount ++;
+  }
+  
+  //
+  // Allocate enough buffer to hold TLS Ciphertext.
+  //
+  BufferOut = AllocateZeroPool (RecordCount * (TLS_RECORD_HEADER_LENGTH + 
TLS_CIPHERTEXT_RECORD_MAX_PAYLOAD_LENGTH));
   if (BufferOut == NULL) {
 Status = EFI_OUT_OF_RESOURCES;
 goto ERROR;
   }
 
   //
-  // Parsing buffer.
+  // Parsing buffer. Received packet may have multiple TLS record messages.
   //
   BufferInPtr = BufferIn;
   TempRecordHeader = (TLS_RECORD_HEADER *) BufferOut;
   while ((UINTN) BufferInPtr < (UINTN) BufferIn + BufferInSize) {
 RecordHeaderIn = (TLS_RECORD_HEADER *) BufferInPtr;
 
-if (RecordHeaderIn->ContentType != TlsContentTypeApplicationData) {
-  Status = EFI_INVALID_PARAMETER;
-  goto ERROR;
-}
-
 ThisPlainMessageSize = RecordHeaderIn->Length;
 
 TlsWrite (TlsInstance->TlsConn, (UINT8 *) (RecordHeaderIn + 1), 
ThisPlainMessageSize);
 
-Ret = TlsCtrlTrafficOut (TlsInstance->TlsConn, (UINT8 
*)(TempRecordHeader), MAX_BUFFER_SIZE - BufferOutSize);
+Ret = TlsCtrlTrafficOut (TlsInstance->TlsConn, (UINT8 
*)(TempRecordHeader), TLS_RECORD_HEADER_LENGTH + 
TLS_CIPHERTEXT_RECORD_MAX_PAYLOAD_LENGTH);
 
 if (Ret > 0) {
   ThisMessageSize = (UINT16) Ret;
 } else {
   //
@@ -127,11 +141,11 @@ TlsEncryptPacket (
   ThisMessageSize = 0;
 }
 
 BufferOutSize += ThisMessageSize;
 
-BufferInPtr += RECORD_HEADER_LEN + ThisPlainMessageSize;
+BufferInPtr += TLS_RECORD_HEADER_LENGTH + ThisPlainMessageSize;
 TempRecordHeader += ThisMessageSize;
   }
 
   FreePool (BufferIn);
   BufferIn = NULL;
@@ -199,10 +213,11 @@ TlsDecryptPacket (
   UINT16  ThisCipherMessageSize;
   TLS_RECORD_HEADER   *TempRecordHeader;
   UINT16  ThisPlainMessageSize;
   UINT8   *BufferOut;
   UINT32  BufferOutSize;
+  UINT32  RecordCount;
   INTNRet;
 
   Status   = EFI_SUCCESS;
   BytesCopied  = 0;
   BufferIn = NULL;
@@ -210,10 +225,11 @@ TlsDecryptPacket (
   BufferInPtr  = NULL;
   RecordHeaderIn   = NULL;
   TempRecordHeader = NULL;
   BufferOut= NULL;
   BufferOutSize= 0;
+  RecordCount  = 0;
   Ret  = 0;
 
   //
   // Calculate the size according to the fragment table.
   //
@@ -240,11 +256,28 @@ TlsDecryptPacket (
   (*FragmentTable)[Index].FragmentLength
   );
 BytesCopied += (*FragmentTable)[Index].FragmentLength;
   }
 
-  BufferOut = AllocateZeroPool (MAX_BUFFER_SIZE);
+  //
+  // Count TLS record number.
+  //
+  BufferInPtr = BufferIn;
+  while ((UINTN) BufferInP

[edk2] [Patch 0/3] Support HTTP large data request via TLS channel.

2018-03-19 Thread Jiaxin Wu
Cc: Karunakar P 
Cc: Fu Siyuan 
Cc: Ye Ting 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu 

Jiaxin Wu (3):
  MdePkg/Tls1.h: Add TLS record header length and max payload length.
  NetworkPkg/TlsDxe: Handle the multiple TLS record messages
encryption/decryption.
  NetworkPkg/HttpDxe: Handle the large data request via HTTPS channel.

 MdePkg/Include/IndustryStandard/Tls1.h |  16 -
 NetworkPkg/HttpDxe/HttpProto.c | 121 -
 NetworkPkg/HttpDxe/HttpsSupport.c  |  17 -
 NetworkPkg/HttpDxe/HttpsSupport.h  |  12 +++-
 NetworkPkg/TlsDxe/TlsImpl.c|  74 +---
 NetworkPkg/TlsDxe/TlsImpl.h|   6 +-
 6 files changed, 178 insertions(+), 68 deletions(-)

-- 
2.16.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 1/3] MdePkg/Tls1.h: Add TLS record header length and max payload length.

2018-03-19 Thread Jiaxin Wu
Cc: Karunakar P 
Cc: Fu Siyuan 
Cc: Ye Ting 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu 
---
 MdePkg/Include/IndustryStandard/Tls1.h | 16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/MdePkg/Include/IndustryStandard/Tls1.h 
b/MdePkg/Include/IndustryStandard/Tls1.h
index 9009291ee3..cccb6db7fb 100644
--- a/MdePkg/Include/IndustryStandard/Tls1.h
+++ b/MdePkg/Include/IndustryStandard/Tls1.h
@@ -1,11 +1,11 @@
 /** @file
   Transport Layer Security  -- TLS 1.0/1.1/1.2 Standard definitions, from RFC 
2246/4346/5246
 
   This file contains common TLS 1.0/1.1/1.2 definitions from RFC 2246/4346/5246
 
-  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
   http://opensource.org/licenses/bsd-license.php
 
@@ -85,9 +85,23 @@ typedef struct {
   UINT8   ContentType;
   EFI_TLS_VERSION Version;
   UINT16  Length;
 } TLS_RECORD_HEADER;
 
+#define TLS_RECORD_HEADER_LENGTH   5
+
+//
+// The length (in bytes) of the TLSPlaintext records payload MUST NOT exceed 
2^14.
+// Refers to section 6.2 of RFC5246. 
+//
+#define TLS_PLAINTEXT_RECORD_MAX_PAYLOAD_LENGTH   16384
+
+//
+// The length (in bytes) of the TLSCiphertext records payload MUST NOT exceed 
2^14 + 2048.
+// Refers to section 6.2 of RFC5246. 
+//
+#define TLS_CIPHERTEXT_RECORD_MAX_PAYLOAD_LENGTH   18432
+
 #pragma pack()
 
 #endif
 
-- 
2.16.2.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 3/3] NetworkPkg/HttpDxe: Handle the large data request via HTTPS channel.

2018-03-19 Thread Jiaxin Wu
Cc: Karunakar P 
Cc: Fu Siyuan 
Cc: Ye Ting 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu 
---
 NetworkPkg/HttpDxe/HttpProto.c| 121 +++---
 NetworkPkg/HttpDxe/HttpsSupport.c |  17 +-
 NetworkPkg/HttpDxe/HttpsSupport.h |  12 +++-
 3 files changed, 111 insertions(+), 39 deletions(-)

diff --git a/NetworkPkg/HttpDxe/HttpProto.c b/NetworkPkg/HttpDxe/HttpProto.c
index d7fe271168..35c4a166c4 100644
--- a/NetworkPkg/HttpDxe/HttpProto.c
+++ b/NetworkPkg/HttpDxe/HttpProto.c
@@ -1,9 +1,9 @@
 /** @file
   Miscellaneous routines for HttpDxe driver.
 
-Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
@@ -1474,64 +1474,101 @@ HttpTransmitTcp (
   EFI_STATUSStatus;
   EFI_TCP4_IO_TOKEN *Tx4Token;
   EFI_TCP4_PROTOCOL *Tcp4;
   EFI_TCP6_IO_TOKEN *Tx6Token;
   EFI_TCP6_PROTOCOL *Tcp6;
-  UINT8 *Buffer;  
-  UINTN BufferSize;
+  UINT8 *TlsRecord;  
+  UINT16PayloadSize;
   NET_FRAGMENT  TempFragment;
+  NET_FRAGMENT  Fragment;
+  UINTN RecordCount;
+  UINTN RemainingLen;
 
   Status= EFI_SUCCESS;
-  Buffer= NULL;
+  TlsRecord = NULL;
+  PayloadSize   = 0;
   TempFragment.Len  = 0;
   TempFragment.Bulk = NULL;
+  Fragment.Len  = 0;
+  Fragment.Bulk = NULL;
+  RecordCount   = 0;
+  RemainingLen  = 0;
 
   //
   // Need to encrypt data.
   //
   if (HttpInstance->UseHttps) {
 //
-// Build BufferOut data
+// Allocate enough buffer for each TLS plaintext records.
 //
-BufferSize = sizeof (TLS_RECORD_HEADER) + TxStringLen;
-Buffer = AllocateZeroPool (BufferSize);
-if (Buffer == NULL) {
+TlsRecord = AllocateZeroPool (TLS_RECORD_HEADER_LENGTH + 
TLS_PLAINTEXT_RECORD_MAX_PAYLOAD_LENGTH);
+if (TlsRecord == NULL) {
   Status = EFI_OUT_OF_RESOURCES;
   return Status;
 }
-((TLS_RECORD_HEADER *) Buffer)->ContentType = 
TlsContentTypeApplicationData;
-((TLS_RECORD_HEADER *) Buffer)->Version.Major = 
HttpInstance->TlsConfigData.Version.Major;
-((TLS_RECORD_HEADER *) Buffer)->Version.Minor = 
HttpInstance->TlsConfigData.Version.Minor;
-((TLS_RECORD_HEADER *) Buffer)->Length = (UINT16) (TxStringLen);
-CopyMem (Buffer + sizeof (TLS_RECORD_HEADER), TxString, TxStringLen);
-
+
 //
-// Encrypt Packet.
+// Allocate enough buffer for all TLS ciphertext records.
 //
-Status = TlsProcessMessage (
-   HttpInstance, 
-   Buffer, 
-   BufferSize, 
-   EfiTlsEncrypt, 
-   &TempFragment
-   );
-
-FreePool (Buffer);
+RecordCount = TxStringLen / TLS_PLAINTEXT_RECORD_MAX_PAYLOAD_LENGTH + 1;
+Fragment.Bulk = AllocateZeroPool (RecordCount * (TLS_RECORD_HEADER_LENGTH 
+ TLS_CIPHERTEXT_RECORD_MAX_PAYLOAD_LENGTH));
+if (Fragment.Bulk == NULL) {
+  Status = EFI_OUT_OF_RESOURCES;
+  goto ON_ERROR;
+}
 
-if (EFI_ERROR (Status)) {
-  return Status;
+//
+// Encrypt each TLS plaintext records.
+//
+RemainingLen = TxStringLen;
+while (RemainingLen != 0) {
+  PayloadSize = (UINT16) MIN (TLS_PLAINTEXT_RECORD_MAX_PAYLOAD_LENGTH, 
RemainingLen);
+  
+  ((TLS_RECORD_HEADER *) TlsRecord)->ContentType = 
TlsContentTypeApplicationData;
+  ((TLS_RECORD_HEADER *) TlsRecord)->Version.Major = 
HttpInstance->TlsConfigData.Version.Major;
+  ((TLS_RECORD_HEADER *) TlsRecord)->Version.Minor = 
HttpInstance->TlsConfigData.Version.Minor;
+  ((TLS_RECORD_HEADER *) TlsRecord)->Length = PayloadSize;
+
+  CopyMem (TlsRecord + TLS_RECORD_HEADER_LENGTH, TxString + (TxStringLen - 
RemainingLen), PayloadSize);
+  
+  Status = TlsProcessMessage (
+ HttpInstance, 
+ TlsRecord, 
+ TLS_RECORD_HEADER_LENGTH + PayloadSize, 
+ EfiTlsEncrypt, 
+ &TempFragment
+ );
+  if (EFI_ERROR (Status)) {
+goto ON_ERROR;
+  }
+
+  //
+  // Record the processed/encrypted Packet. 
+  //
+  CopyMem (Fragment.Bulk + Fragment.Len, TempFragment.Bulk, 
TempFragment.Len);
+  Fragment.Len += TempFragment.Len;
+
+  FreePool (TempFragment.Bulk);
+  TempFra

[edk2] [Patch] NetworkPkg/UefiPxeBcDxe: Configure the ARP Instance/RouteTable with new address

2018-03-19 Thread Jiaxin Wu
After completed a DHCP D.O.R.A process and got the new address, the ARP Instance
and RouteTable should be configured so as to avoid the later Pxe.Arp failure.

Cc: Fu Siyuan 
Cc: Ye Ting 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu 
---
 NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c| 26 +++---
 NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c | 66 --
 2 files changed, 52 insertions(+), 40 deletions(-)

diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c 
b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
index d3146c3a7e..b828d24288 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
@@ -2001,11 +2001,10 @@ EfiPxeBcSetStationIP (
   )
 {
   EFI_STATUS  Status;
   PXEBC_PRIVATE_DATA  *Private;
   EFI_PXE_BASE_CODE_MODE  *Mode;
-  EFI_ARP_CONFIG_DATA ArpConfigData;
 
   if (This == NULL) {
 return EFI_INVALID_PARAMETER;
   }
 
@@ -2041,31 +2040,10 @@ EfiPxeBcSetStationIP (
 //
 Status = PxeBcRegisterIp6Address (Private, &NewStationIp->v6);
 if (EFI_ERROR (Status)) {
   goto ON_EXIT;
 }
-  } else if (!Mode->UsingIpv6 && NewStationIp != NULL) {
-//
-// Configure the corresponding ARP with the IPv4 address.
-//
-ZeroMem (&ArpConfigData, sizeof (EFI_ARP_CONFIG_DATA));
-
-ArpConfigData.SwAddressType   = 0x0800;
-ArpConfigData.SwAddressLength = (UINT8) sizeof (EFI_IPv4_ADDRESS);
-ArpConfigData.StationAddress  = &NewStationIp->v4;
-
-Private->Arp->Configure (Private->Arp, NULL);
-Private->Arp->Configure (Private->Arp, &ArpConfigData);
-
-if (NewSubnetMask != NULL) {
-  Mode->RouteTableEntries= 1;
-  Mode->RouteTable[0].IpAddr.Addr[0] = NewStationIp->Addr[0] & 
NewSubnetMask->Addr[0];
-  Mode->RouteTable[0].SubnetMask.Addr[0] = NewSubnetMask->Addr[0];
-  Mode->RouteTable[0].GwAddr.Addr[0] = 0;
-}
-
-Private->IsAddressOk = TRUE;
   }
 
   if (NewStationIp != NULL) {
 CopyMem (&Mode->StationIp, NewStationIp, sizeof (EFI_IP_ADDRESS));
 CopyMem (&Private->StationIp, NewStationIp, sizeof (EFI_IP_ADDRESS));
@@ -2075,10 +2053,14 @@ EfiPxeBcSetStationIP (
 CopyMem (&Mode->SubnetMask, NewSubnetMask, sizeof (EFI_IP_ADDRESS));
 CopyMem (&Private->SubnetMask ,NewSubnetMask, sizeof (EFI_IP_ADDRESS));
   }
 
   Status = PxeBcFlushStationIp (Private, NewStationIp, NewSubnetMask);
+  if (!EFI_ERROR (Status)) {
+Private->IsAddressOk = TRUE;
+  }
+  
 ON_EXIT:
   return Status;
 }
 
 
diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c 
b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
index 47bb7c5dbb..4b6f8c9c7f 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
@@ -1,9 +1,9 @@
 /** @file
   Support functions implementation for UefiPxeBc Driver.
 
-  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
+  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
   http://opensource.org/licenses/bsd-license.php.
@@ -34,21 +34,23 @@ PxeBcFlushStationIp (
   EFI_IP_ADDRESS   *SubnetMask OPTIONAL
   )
 {
   EFI_PXE_BASE_CODE_MODE   *Mode;
   EFI_STATUS   Status;
+  EFI_ARP_CONFIG_DATA  ArpConfigData;
 
   Mode   = Private->PxeBc.Mode;
   Status = EFI_SUCCESS;
+  ZeroMem (&ArpConfigData, sizeof (EFI_ARP_CONFIG_DATA));
 
-  if (Mode->UsingIpv6) {
-
-if (StationIp != NULL) {
-  CopyMem (&Private->Udp6CfgData.StationAddress, StationIp, sizeof 
(EFI_IPv6_ADDRESS));
-  CopyMem (&Private->Ip6CfgData.StationAddress, StationIp, sizeof 
(EFI_IPv6_ADDRESS));
-}
-
+  if (Mode->UsingIpv6 && StationIp != NULL) {
+//
+// Overwrite Udp6CfgData/Ip6CfgData StationAddress.
+//
+CopyMem (&Private->Udp6CfgData.StationAddress, StationIp, sizeof 
(EFI_IPv6_ADDRESS));
+CopyMem (&Private->Ip6CfgData.StationAddress, StationIp, sizeof 
(EFI_IPv6_ADDRESS));
+
 //
 // Reconfigure the Ip6 instance to capture background ICMP6 packets with 
new station Ip address.
 //
 Private->Ip6->Cancel (Private->Ip6, &Private->Icmp6Token);
 Private->Ip6->Configure (Private->Ip6, NULL);
@@ -59,31 +61,59 @@ PxeBcFlushStationIp (
 }
 
 Status = Private->Ip6->Receive (Private->Ip6, &Private->Icmp6Token);
   } else {
 if (StationIp != NULL) {
+  //
+  // Reconfigure the ARP instance with station Ip address.
+  //
+  ArpConfigData.SwAddressType   = 0x0800;
+  ArpConfigData.SwAddressLength = (UINT8) sizeof (EFI_IPv4_ADDRESS);
+  ArpConfigData.StationAddress 

[edk2] [Patch] MdeModulePkg/DxeHttpLib: Fix the incorrect return status if URI port is invalid

2017-03-26 Thread Jiaxin Wu
Cc: Zhang Lubo 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c | 15 +++
 MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.h |  5 -
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c 
b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
index 2ff04ff..8e29213 100644
--- a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
+++ b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
@@ -690,18 +690,22 @@ HttpUrlGetPort (
  OUT  UINT16 *Port
   )
 {
   CHAR8 *PortString;
   EFI_STATUSStatus;
+  UINTN Index;
   UINTN Data;
   UINT32ResultLength;
   HTTP_URL_PARSER  *Parser;
 
   if (Url == NULL || UrlParser == NULL || Port == NULL) {
 return EFI_INVALID_PARAMETER;
   }
 
+  *Port = 0;
+  Index = 0;
+
   Parser = (HTTP_URL_PARSER*) UrlParser;
 
   if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_PORT)) == 0) {
 return EFI_INVALID_PARAMETER;
   }
@@ -721,12 +725,23 @@ HttpUrlGetPort (
 return Status;
   }
 
   PortString[ResultLength] = '\0';
 
+  while (Index < ResultLength) {
+if (!NET_IS_DIGIT (PortString[Index])) {
+  return EFI_INVALID_PARAMETER;
+}
+Index ++;
+  }
+
   Status =  AsciiStrDecimalToUintnS (Url + 
Parser->FieldData[HTTP_URI_FIELD_PORT].Offset, (CHAR8 **) NULL, &Data);
 
+  if (Data > HTTP_URI_PORT_MAX_NUM || Data < HTTP_URI_PORT_MIN_NUM) {
+return EFI_INVALID_PARAMETER;
+  }
+
   *Port = (UINT16) Data;
   return Status;
 }
 
 /**
diff --git a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.h 
b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.h
index 0d0ad3d..5ee0fdc 100644
--- a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.h
+++ b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.h
@@ -1,9 +1,9 @@
 /** @file
 Header file for HttpLib.
 
-  Copyright (c) 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
   (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -48,10 +48,13 @@ Header file for HttpLib.
 #define   HTTP_URI_FIELD_USERINFO 5
 #define   HTTP_URI_FIELD_HOST 6
 #define   HTTP_URI_FIELD_PORT 7
 #define   HTTP_URI_FIELD_MAX  8
 
+#define   HTTP_URI_PORT_MIN_NUM   0
+#define   HTTP_URI_PORT_MAX_NUM   65535
+
 //
 // Structure to store the parse result of a HTTP URL.
 //
 typedef struct {
   UINT32  Offset;
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] MdeModulePkg/DxeHttpLib: Avoid the pointless comparison of UINTN with zero

2017-03-31 Thread Jiaxin Wu
UINTN is unsigned integer, so it's pointless to compare it with zero.

Cc: Bi Dandan 
Cc: Zhang Lubo 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c | 2 +-
 MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.h | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c 
b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
index 8e29213..8421caa 100644
--- a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
+++ b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
@@ -734,11 +734,11 @@ HttpUrlGetPort (
 Index ++;
   }
 
   Status =  AsciiStrDecimalToUintnS (Url + 
Parser->FieldData[HTTP_URI_FIELD_PORT].Offset, (CHAR8 **) NULL, &Data);
 
-  if (Data > HTTP_URI_PORT_MAX_NUM || Data < HTTP_URI_PORT_MIN_NUM) {
+  if (Data > HTTP_URI_PORT_MAX_NUM) {
 return EFI_INVALID_PARAMETER;
   }
 
   *Port = (UINT16) Data;
   return Status;
diff --git a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.h 
b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.h
index 5ee0fdc..af82c16 100644
--- a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.h
+++ b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.h
@@ -48,11 +48,10 @@ Header file for HttpLib.
 #define   HTTP_URI_FIELD_USERINFO 5
 #define   HTTP_URI_FIELD_HOST 6
 #define   HTTP_URI_FIELD_PORT 7
 #define   HTTP_URI_FIELD_MAX  8
 
-#define   HTTP_URI_PORT_MIN_NUM   0
 #define   HTTP_URI_PORT_MAX_NUM   65535
 
 //
 // Structure to store the parse result of a HTTP URL.
 //
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] NetworkPkg/TlsAuthConfigDxe: Close and free the file related resource

2017-04-09 Thread Jiaxin Wu
TlsAuthConfigDxe open file by FileExplorerLib. It need to close
file handler and free file related resource in some cases.
* User enrolls Cert by escape the Config page.
* The Cert is not X509 type.
* User chooses another file after he selected a file.

Cc: Zhang Chao B 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c | 43 -
 1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c 
b/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c
index 81f7e7d..23442fe 100644
--- a/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c
+++ b/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c
@@ -1559,11 +1559,12 @@ TlsAuthConfigAccessCallback (
   }
 
   HiiGetBrowserData (&gTlsAuthConfigGuid, mTlsAuthConfigStorageName, 
BufferSize, (UINT8 *) IfrNvData);
 
   if ((Action != EFI_BROWSER_ACTION_CHANGED) &&
-  (Action != EFI_BROWSER_ACTION_CHANGING)) {
+  (Action != EFI_BROWSER_ACTION_CHANGING) && 
+  (Action != EFI_BROWSER_ACTION_FORM_CLOSE)) {
 Status = EFI_UNSUPPORTED;
 goto EXIT;
   }
 
   if (Action == EFI_BROWSER_ACTION_CHANGING) {
@@ -1590,26 +1591,54 @@ TlsAuthConfigAccessCallback (
   // Refresh selected file.
   //
   CleanUpPage (LabelId, Private);
   break;
 case KEY_TLS_AUTH_CONFIG_ENROLL_CERT_FROM_FILE:
+  //
+  // If the file is already opened, then close and 
+  // free the related resource first. 
+  //
+  if (Private->FileContext->FHandle != NULL) {
+CloseFile (Private->FileContext->FHandle);
+Private->FileContext->FHandle = NULL;
+if (Private->FileContext->FileName!= NULL){
+  FreePool(Private->FileContext->FileName);
+  Private->FileContext->FileName = NULL;
+}
+  }
+  
   ChooseFile( NULL, NULL, UpdateCAFromFile, &File);
   break;
 
 case KEY_TLS_AUTH_CONFIG_VALUE_SAVE_AND_EXIT:
   Status = EnrollCertDatabase (Private, EFI_TLS_CA_CERTIFICATE_VARIABLE);
   if (EFI_ERROR (Status)) {
+//
+// Close File and free the related resource. 
+//
+if (Private->FileContext->FHandle != NULL) {
+  CloseFile (Private->FileContext->FHandle);
+  Private->FileContext->FHandle = NULL;
+  if (Private->FileContext->FileName!= NULL){
+FreePool(Private->FileContext->FileName);
+Private->FileContext->FileName = NULL;
+  }
+}
+
 CreatePopUp (
   EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
   &Key,
   L"ERROR: Enroll Cert Failure!",
   NULL
   );
   }
   break;
 
 case KEY_TLS_AUTH_CONFIG_VALUE_NO_SAVE_AND_EXIT:
+  //
+  // Close File and free the related resource. 
+  //
   if (Private->FileContext->FHandle != NULL) {
 CloseFile (Private->FileContext->FHandle);
 Private->FileContext->FHandle = NULL;
 if (Private->FileContext->FileName!= NULL){
   FreePool(Private->FileContext->FileName);
@@ -1665,10 +1694,22 @@ TlsAuthConfigAccessCallback (
   *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
   break;
 default:
   break;
 }
+  } else if (Action == EFI_BROWSER_ACTION_FORM_CLOSE) {
+//
+// Close File and free the related resource. 
+//
+if (Private->FileContext->FHandle != NULL) {
+  CloseFile (Private->FileContext->FHandle);
+  Private->FileContext->FHandle = NULL;
+  if (Private->FileContext->FileName!= NULL){
+FreePool(Private->FileContext->FileName);
+Private->FileContext->FileName = NULL;
+  }
+}
   }
 
 EXIT:
 
   if (!EFI_ERROR (Status)) {
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] NetworkPkg/HttpDxe: Fix HTTP download OS image over 4G size failure

2017-04-13 Thread Jiaxin Wu
UINT32 integer overflow will happen once the download OS image over
4G size. This patch is to fix this issue.

Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Zhang Lubo 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/HttpDxe/HttpProto.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/NetworkPkg/HttpDxe/HttpProto.c b/NetworkPkg/HttpDxe/HttpProto.c
index 3d61ba2..3fda294 100644
--- a/NetworkPkg/HttpDxe/HttpProto.c
+++ b/NetworkPkg/HttpDxe/HttpProto.c
@@ -2029,24 +2029,24 @@ HttpTcpReceiveBody (
 ASSERT (Tcp4 != NULL);
   }
   
   if (HttpInstance->LocalAddressIsIPv6) {
 Rx6Token = &Wrap->TcpWrap.Rx6Token;
-Rx6Token ->Packet.RxData->DataLength = (UINT32) HttpMsg->BodyLength;
-Rx6Token ->Packet.RxData->FragmentTable[0].FragmentLength = (UINT32) 
HttpMsg->BodyLength;
+Rx6Token ->Packet.RxData->DataLength = (UINT32) MIN (MAX_UINT32, 
HttpMsg->BodyLength);
+Rx6Token ->Packet.RxData->FragmentTable[0].FragmentLength = (UINT32) MIN 
(MAX_UINT32, HttpMsg->BodyLength);
 Rx6Token ->Packet.RxData->FragmentTable[0].FragmentBuffer = (VOID *) 
HttpMsg->Body;
 Rx6Token->CompletionToken.Status = EFI_NOT_READY;
 
 Status = Tcp6->Receive (Tcp6, Rx6Token);
 if (EFI_ERROR (Status)) {
   DEBUG ((EFI_D_ERROR, "Tcp6 receive failed: %r\n", Status));
   return Status;
 }
   } else {
 Rx4Token = &Wrap->TcpWrap.Rx4Token;
-Rx4Token->Packet.RxData->DataLength = (UINT32) HttpMsg->BodyLength;
-Rx4Token->Packet.RxData->FragmentTable[0].FragmentLength = (UINT32) 
HttpMsg->BodyLength;
+Rx4Token->Packet.RxData->DataLength = (UINT32) MIN (MAX_UINT32, 
HttpMsg->BodyLength);
+Rx4Token->Packet.RxData->FragmentTable[0].FragmentLength = (UINT32) MIN 
(MAX_UINT32, HttpMsg->BodyLength);
 Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer = (VOID *) 
HttpMsg->Body;
 
 Rx4Token->CompletionToken.Status = EFI_NOT_READY;
 Status = Tcp4->Receive (Tcp4, Rx4Token);
 if (EFI_ERROR (Status)) {
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] MdeModulePkg/Ip4Dxe: Fix the incorrect RemoveEntryList

2017-04-16 Thread Jiaxin Wu
Cc: Subramanian Sriram 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Zhang Lubo 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c 
b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c
index 7512a00..d29d873 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c
@@ -853,11 +853,11 @@ Ip4OnArpResolvedDpc (
 //
 InsertTailList (&Interface->SentFrames, &Token->Link);
 
 Status = Interface->Mnp->Transmit (Interface->Mnp, &Token->MnpToken);
 if (EFI_ERROR (Status)) {
-  RemoveEntryList (Entry);
+  RemoveEntryList (&Token->Link);
   Token->CallBack (Token->IpInstance, Token->Packet, Status, 0, 
Token->Context);
 
   Ip4FreeLinkTxToken (Token);
   continue;
 }
@@ -1079,11 +1079,11 @@ SEND_NOW:
   // Remove it if the returned status is not EFI_SUCCESS.
   //
   InsertTailList (&Interface->SentFrames, &Token->Link);
   Status = Interface->Mnp->Transmit (Interface->Mnp, &Token->MnpToken);
   if (EFI_ERROR (Status)) {
-RemoveEntryList (&Interface->SentFrames);
+RemoveEntryList (&Token->Link);
 goto ON_ERROR;
   }
 
   return EFI_SUCCESS;
 
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] NetworkPkg: Correct the proxy DHCP offer handing

2017-04-16 Thread Jiaxin Wu
When PXE10/WFM11a offer received, we should only cache
the first PXE10/WFM11a offer, and discard the others. But
Current we discard all PXE10/WFM11a offer. This patch is
to fix this issue.

Cc: RickF 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Zhang Lubo 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c | 5 +++--
 NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c 
b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c
index 5497390..97829e9 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c
@@ -1,9 +1,9 @@
 /** @file
   Functions implementation related with DHCPv4 for UefiPxeBc Driver.
 
-  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
   http://opensource.org/licenses/bsd-license.php.
@@ -868,11 +868,12 @@ PxeBcCacheDhcp4Offer (
 //
 // Cache all proxy BINL offers.
 //
 Private->OfferIndex[OfferType][Private->OfferCount[OfferType]] = 
Private->OfferNum;
 Private->OfferCount[OfferType]++;
-  } else if (Private->OfferCount[OfferType] > 0) {
+  } else if ((OfferType == PxeOfferTypeProxyPxe10 || OfferType == 
PxeOfferTypeProxyWfm11a) && 
+ Private->OfferCount[OfferType] < 1) {
 //
 // Only cache the first PXE10/WFM11a offer, and discard the others.
 //
 Private->OfferIndex[OfferType][0] = Private->OfferNum;
 Private->OfferCount[OfferType]= 1;
diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c 
b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
index a295b82..4cd1770 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
@@ -1,10 +1,10 @@
 /** @file
   Functions implementation related with DHCPv6 for UefiPxeBc Driver.
 
   (C) Copyright 2014 Hewlett-Packard Development Company, L.P.
-  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
   http://opensource.org/licenses/bsd-license.php.
@@ -1195,11 +1195,12 @@ PxeBcCacheDhcp6Offer (
   //
   // Cache all proxy BINL offers.
   //
   Private->OfferIndex[OfferType][Private->OfferCount[OfferType]] = 
Private->OfferNum;
   Private->OfferCount[OfferType]++;
-} else if (Private->OfferCount[OfferType] > 0) {
+} else if ((OfferType == PxeOfferTypeProxyPxe10 || OfferType == 
PxeOfferTypeProxyWfm11a) && 
+ Private->OfferCount[OfferType] < 1) {
   //
   // Only cache the first PXE10/WFM11a offer, and discard the others.
   //
   Private->OfferIndex[OfferType][0] = Private->OfferNum;
   Private->OfferCount[OfferType]= 1;
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v2] NetworkPkg/TlsAuthConfigDxe: Close and free the file related resource

2017-04-16 Thread Jiaxin Wu
v2:
* Define one new internal function to clean the file content.

TlsAuthConfigDxe open file by FileExplorerLib. It need to close
file handler and free file related resource in some cases.
* User enrolls Cert by escape the Config page.
* The Cert is not X509 type.
* User chooses another file after he selected a file.

Cc: Zhang Chao B 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c | 49 +
 1 file changed, 25 insertions(+), 24 deletions(-)

diff --git a/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c 
b/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c
index 81f7e7d..faefc72 100644
--- a/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c
+++ b/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c
@@ -294,11 +294,11 @@ ON_EXIT:
 }
 
 /**
   Delete one entry from cert database.
 
-  @param[in]PrivateData Module's private data.
+  @param[in]Private Module's private data.
   @param[in]VariableNameThe variable name of the database.
   @param[in]VendorGuid  A unique identifier for the vendor.
   @param[in]LabelNumber Label number to insert opcodes.
   @param[in]FormId  Form ID of current page.
   @param[in]QuestionIdBase  Base question id of the cert list.
@@ -475,22 +475,27 @@ ON_EXIT:
);
 }
 
 
 /**
-  Close an open file handle.
+  Clean the file related resource.
 
-  @param[in] FileHandle   The file handle to close.
+  @param[in]Private Module's private data.
 
 **/
 VOID
-CloseFile (
-  IN EFI_FILE_HANDLE   FileHandle
+CleanFileContext (
+  IN TLS_AUTH_CONFIG_PRIVATE_DATA *Private
   )
 {
-  if (FileHandle != NULL) {
-FileHandle->Close (FileHandle);
+  if (Private->FileContext->FHandle != NULL) {
+Private->FileContext->FHandle->Close (Private->FileContext->FHandle);
+Private->FileContext->FHandle = NULL;
+if (Private->FileContext->FileName!= NULL){
+  FreePool(Private->FileContext->FileName);
+  Private->FileContext->FileName = NULL;
+}
   }
 }
 
 /**
   Read file content into BufferPtr, the size of the allocate buffer
@@ -871,18 +876,11 @@ EnrollX509toVariable (
   if (EFI_ERROR (Status)) {
 goto ON_EXIT;
   }
 
 ON_EXIT:
-
-  CloseFile (Private->FileContext->FHandle);
-  if (Private->FileContext->FileName != NULL) {
-FreePool(Private->FileContext->FileName);
-Private->FileContext->FileName = NULL;
-  }
-
-  Private->FileContext->FHandle = NULL;
+  CleanFileContext (Private);
 
   if (Private->CertGuid != NULL) {
 FreePool (Private->CertGuid);
 Private->CertGuid = NULL;
   }
@@ -1559,11 +1557,12 @@ TlsAuthConfigAccessCallback (
   }
 
   HiiGetBrowserData (&gTlsAuthConfigGuid, mTlsAuthConfigStorageName, 
BufferSize, (UINT8 *) IfrNvData);
 
   if ((Action != EFI_BROWSER_ACTION_CHANGED) &&
-  (Action != EFI_BROWSER_ACTION_CHANGING)) {
+  (Action != EFI_BROWSER_ACTION_CHANGING) && 
+  (Action != EFI_BROWSER_ACTION_FORM_CLOSE)) {
 Status = EFI_UNSUPPORTED;
 goto EXIT;
   }
 
   if (Action == EFI_BROWSER_ACTION_CHANGING) {
@@ -1590,34 +1589,34 @@ TlsAuthConfigAccessCallback (
   // Refresh selected file.
   //
   CleanUpPage (LabelId, Private);
   break;
 case KEY_TLS_AUTH_CONFIG_ENROLL_CERT_FROM_FILE:
+  //
+  // If the file is already opened, clean the file related resource first. 
+  //
+  CleanFileContext (Private);
+  
   ChooseFile( NULL, NULL, UpdateCAFromFile, &File);
   break;
 
 case KEY_TLS_AUTH_CONFIG_VALUE_SAVE_AND_EXIT:
   Status = EnrollCertDatabase (Private, EFI_TLS_CA_CERTIFICATE_VARIABLE);
   if (EFI_ERROR (Status)) {
+CleanFileContext (Private);
+
 CreatePopUp (
   EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
   &Key,
   L"ERROR: Enroll Cert Failure!",
   NULL
   );
   }
   break;
 
 case KEY_TLS_AUTH_CONFIG_VALUE_NO_SAVE_AND_EXIT:
-  if (Private->FileContext->FHandle != NULL) {
-CloseFile (Private->FileContext->FHandle);
-Private->FileContext->FHandle = NULL;
-if (Private->FileContext->FileName!= NULL){
-  FreePool(Private->FileContext->FileName);
-  Private->FileContext->FileName = NULL;
-}
-  }
+  CleanFileContext (Private);
 
   if (Private->CertGuid!= NULL) {
 FreePool (Private->CertGuid);
 Private->CertGuid = NULL;
   }
@@ -1665,10 +1664,12 @@ TlsAuthConfigAccessCallback (
   *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
   break;
 default:
   break;
 }
+  } else if (Action == EFI_BROWSER_ACTION_FORM_CLOSE) {
+CleanFileContext (Private);
   }
 
 EXIT:
 
   if (!EFI_ERROR (Status)) {
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo

[edk2] [Patch] MdeModulePkg/DeviceManagerUiLib: Fix the network device MAC display issue

2017-04-17 Thread Jiaxin Wu
Network device tile (STR_FORM_NETWORK_DEVICE_TITLE) is dynamic adjusted
according the different MAC value. So, the string value shouldn't be treated
as a constant string (Network Device). Otherwise, the display will be
incorrect.

Reproduce: Device Manager->Network Device List, select to enter MAC, then to
press ESC back to previous page, then re-enter, found each enter/ESC operation,
the MAC address display +1.

Cc: Eric Dong 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c 
b/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c
index 5098b70..8630ab0 100644
--- a/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c
+++ b/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c
@@ -538,17 +538,15 @@ CreateDeviceManagerForm(
 
   //
   // Update the network device form titile.
   //
   if (NextShowFormId == NETWORK_DEVICE_FORM_ID) {
-String = HiiGetString (HiiHandle, STRING_TOKEN 
(STR_FORM_NETWORK_DEVICE_TITLE), NULL);
 NewStringLen = StrLen(mSelectedMacAddrString) * 2;
-NewStringLen += (StrLen(String) + 2) * 2;
+NewStringLen += (StrLen (L"Network Device") + 2) * 2;
 NewStringTitle = AllocatePool (NewStringLen);
-UnicodeSPrint (NewStringTitle, NewStringLen, L"%s %s", String, 
mSelectedMacAddrString);
+UnicodeSPrint (NewStringTitle, NewStringLen, L"Network Device %s", 
mSelectedMacAddrString);
 HiiSetString (HiiHandle, STRING_TOKEN (STR_FORM_NETWORK_DEVICE_TITLE), 
NewStringTitle, NULL);
-FreePool (String);
 FreePool (NewStringTitle);
   }
 
   //
   // Allocate space for creation of UpdateData Buffer
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v2] MdeModulePkg/DeviceManagerUiLib: Fix the network device MAC display issue

2017-04-20 Thread Jiaxin Wu
v2:
* Define new STR_FORM_NETWORK_DEVICE_TITLE_HEAD for L" Network Device "
instead of hard code in the code.

Network device tile (STR_FORM_NETWORK_DEVICE_TITLE) is dynamic adjusted
according the different MAC value. So, the string value shouldn't be treated
as a constant string (Network Device). Otherwise, the display will be
incorrect.

Reproduce: Device Manager->Network Device List, select to enter MAC, then to
press ESC back to previous page, then re-enter, found each enter/ESC operation,
the MAC address display +1.

Cc: Eric Dong 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c  | 8 
 MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerStrings.uni | 5 +++--
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c 
b/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c
index 5098b70..d2d3d76 100644
--- a/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c
+++ b/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c
@@ -538,16 +538,16 @@ CreateDeviceManagerForm(
 
   //
   // Update the network device form titile.
   //
   if (NextShowFormId == NETWORK_DEVICE_FORM_ID) {
-String = HiiGetString (HiiHandle, STRING_TOKEN 
(STR_FORM_NETWORK_DEVICE_TITLE), NULL);
-NewStringLen = StrLen(mSelectedMacAddrString) * 2;
-NewStringLen += (StrLen(String) + 2) * 2;
+String = HiiGetString (HiiHandle, STRING_TOKEN 
(STR_FORM_NETWORK_DEVICE_TITLE_HEAD), NULL);
+NewStringLen = StrLen (mSelectedMacAddrString) * 2;
+NewStringLen += (StrLen (String) + 2) * 2;
 NewStringTitle = AllocatePool (NewStringLen);
 UnicodeSPrint (NewStringTitle, NewStringLen, L"%s %s", String, 
mSelectedMacAddrString);
-HiiSetString (HiiHandle, STRING_TOKEN (STR_FORM_NETWORK_DEVICE_TITLE), 
NewStringTitle, NULL);
+HiiSetString (HiiHandle, STRING_TOKEN (STR_FORM_NETWORK_DEVICE_TITLE), 
NewStringTitle, NULL);
 FreePool (String);
 FreePool (NewStringTitle);
   }
 
   //
diff --git a/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerStrings.uni 
b/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerStrings.uni
index 061e4be..55d03d6 100644
--- a/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerStrings.uni
+++ b/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerStrings.uni
@@ -1,10 +1,10 @@
 ///** @file
 //
 //  String definitions for the Device Manager.
 //
-//  Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.
+//  Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
 //  This program and the accompanying materials
 //  are licensed and made available under the terms and conditions of the BSD 
License
 //  which accompanies this distribution.  The full text of the license may be 
found at
 //  http://opensource.org/licenses/bsd-license.php
 //  
@@ -40,11 +40,12 @@
#language fr-FR  "Missing String"
 #string STR_EMPTY_STRING   #language en-US  ""
#language fr-FR  ""
 #string STR_EXIT_STRING#language en-US  "Press ESC to exit."
#language fr-FR  "Press ESC to exit."
-#string STR_FORM_NETWORK_DEVICE_TITLE  #language en-US  "Network Device"
+#string STR_FORM_NETWORK_DEVICE_TITLE_HEAD  #language en-US  "Network Device"
+#string STR_FORM_NETWORK_DEVICE_TITLE   #language en-US  "Network Device"
#language fr-FR  "Network Device"
 #string STR_FORM_NETWORK_DEVICE_HELP   #language en-US  "Network Device 
Help..."
#language fr-FR  "Network Device 
Help..."
 #string STR_NETWORK_DEVICE_STRING  #language en-US  "Network Device"
#language fr-FR  "Network Device"
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] MdeModulePkg/Mtftp4Dxe: Add invalid ServerIp check during MTFTP configuration

2017-04-20 Thread Jiaxin Wu
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c 
b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c
index 5494231..54384e1 100644
--- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c
+++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c
@@ -1,10 +1,10 @@
 /** @file
   Interface routine for Mtftp4.
   
 (C) Copyright 2014 Hewlett-Packard Development Company, L.P.
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -665,10 +665,14 @@ EfiMtftp4Configure (
 Ip   = NTOHL (Ip);
 Netmask  = NTOHL (Netmask);
 Gateway  = NTOHL (Gateway);
 ServerIp = NTOHL (ServerIp);
 
+if (ServerIp == 0 || IP4_IS_LOCAL_BROADCAST (ServerIp)) {
+  return EFI_INVALID_PARAMETER;
+}
+
 if (!ConfigData->UseDefaultSetting &&
 ((!IP4_IS_VALID_NETMASK (Netmask) || (Netmask != 0 && !NetIp4IsUnicast 
(Ip, Netmask) {
 
   return EFI_INVALID_PARAMETER;
 }
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v3] MdeModulePkg/DeviceManagerUiLib: Fix the network device MAC display issue

2017-04-20 Thread Jiaxin Wu
v3:
* Add NULL string check.

v2:
* Define new STR_FORM_NETWORK_DEVICE_TITLE_HEAD for L" Network Device "
instead of hard code in the code.

Network device tile (STR_FORM_NETWORK_DEVICE_TITLE) is dynamic adjusted
according the different MAC value. So, the string value shouldn't be treated
as a constant string (Network Device). Otherwise, the display will be
incorrect.

Reproduce: Device Manager->Network Device List, select to enter MAC, then to
press ESC back to previous page, then re-enter, found each enter/ESC operation,
the MAC address display +1.

Cc: Eric Dong 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c   | 11 +++
 .../Library/DeviceManagerUiLib/DeviceManagerStrings.uni   |  5 +++--
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c 
b/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c
index 5098b70..23ae6c5 100644
--- a/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c
+++ b/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c
@@ -538,16 +538,19 @@ CreateDeviceManagerForm(
 
   //
   // Update the network device form titile.
   //
   if (NextShowFormId == NETWORK_DEVICE_FORM_ID) {
-String = HiiGetString (HiiHandle, STRING_TOKEN 
(STR_FORM_NETWORK_DEVICE_TITLE), NULL);
-NewStringLen = StrLen(mSelectedMacAddrString) * 2;
-NewStringLen += (StrLen(String) + 2) * 2;
+String = HiiGetString (HiiHandle, STRING_TOKEN 
(STR_FORM_NETWORK_DEVICE_TITLE_HEAD), NULL);
+if (String == NULL) {
+  return;
+}
+NewStringLen = StrLen (mSelectedMacAddrString) * 2;
+NewStringLen += (StrLen (String) + 2) * 2;
 NewStringTitle = AllocatePool (NewStringLen);
 UnicodeSPrint (NewStringTitle, NewStringLen, L"%s %s", String, 
mSelectedMacAddrString);
-HiiSetString (HiiHandle, STRING_TOKEN (STR_FORM_NETWORK_DEVICE_TITLE), 
NewStringTitle, NULL);
+HiiSetString (HiiHandle, STRING_TOKEN (STR_FORM_NETWORK_DEVICE_TITLE), 
NewStringTitle, NULL);
 FreePool (String);
 FreePool (NewStringTitle);
   }
 
   //
diff --git a/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerStrings.uni 
b/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerStrings.uni
index 061e4be..55d03d6 100644
--- a/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerStrings.uni
+++ b/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerStrings.uni
@@ -1,10 +1,10 @@
 ///** @file
 //
 //  String definitions for the Device Manager.
 //
-//  Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.
+//  Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
 //  This program and the accompanying materials
 //  are licensed and made available under the terms and conditions of the BSD 
License
 //  which accompanies this distribution.  The full text of the license may be 
found at
 //  http://opensource.org/licenses/bsd-license.php
 //  
@@ -40,11 +40,12 @@
#language fr-FR  "Missing String"
 #string STR_EMPTY_STRING   #language en-US  ""
#language fr-FR  ""
 #string STR_EXIT_STRING#language en-US  "Press ESC to exit."
#language fr-FR  "Press ESC to exit."
-#string STR_FORM_NETWORK_DEVICE_TITLE  #language en-US  "Network Device"
+#string STR_FORM_NETWORK_DEVICE_TITLE_HEAD  #language en-US  "Network Device"
+#string STR_FORM_NETWORK_DEVICE_TITLE   #language en-US  "Network Device"
#language fr-FR  "Network Device"
 #string STR_FORM_NETWORK_DEVICE_HELP   #language en-US  "Network Device 
Help..."
#language fr-FR  "Network Device 
Help..."
 #string STR_NETWORK_DEVICE_STRING  #language en-US  "Network Device"
#language fr-FR  "Network Device"
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] MdeModulePkg/Ip4Dxe: Refine the IPv4 configuration help info

2017-04-20 Thread Jiaxin Wu
Below value indicate whether network address configured successfully
or not:
Network Device List->MAC->IPv4 Network Configuration->Configured.

This patch is to refine its help info.

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2.vfr| 4 ++--
 MdeModulePkg/Universal/Network/Ip4Dxe/Ip4DxeStrings.uni | 3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2.vfr 
b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2.vfr
index a18db22..1f45e9f 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2.vfr
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2.vfr
@@ -1,9 +1,9 @@
 /** @file
   Vfr file for IP4Dxe.
 
-Copyright (c) 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -29,11 +29,11 @@ formset
   form formid = FORMID_MAIN_FORM,
 title  = STRING_TOKEN(STR_IP4_DEVICE_FORM_TITLE);
 
 checkbox varid = IP4_CONFIG2_IFR_NVDATA.Configure,
 prompt = STRING_TOKEN(STR_IP4_CONFIGURE),
-help   = STRING_TOKEN(STR_IP4_CONFIGURE),
+help   = STRING_TOKEN(STR_IP4_CONFIGURE_HELP),
 flags  = INTERACTIVE,
 key= KEY_ENABLE,
 endcheckbox;
 
 suppressif ideqval IP4_CONFIG2_IFR_NVDATA.Configure == 0x00;
diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4DxeStrings.uni 
b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4DxeStrings.uni
index a491378..0546cea 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4DxeStrings.uni
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4DxeStrings.uni
@@ -1,9 +1,9 @@
 // /** @file
 //   String definitions for Ip4Config2 formset
 
-// Copyright (c) 2015, Intel Corporation. All rights reserved.
+// Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
 // This program and the accompanying materials
 // are licensed and made available under the terms and conditions of the BSD 
License
 // which accompanies this distribution.  The full text of the license may be 
found at
 // http://opensource.org/licenses/bsd-license.php
 //
@@ -20,10 +20,11 @@
 #string STR_IP4_CONFIG2_FORM_TITLE#language en-US "IPv4 Network 
Configuration"
 #string STR_IP4_CONFIG2_FORM_HELP #language en-US "Configure network 
parameters."
 #string STR_IP4_DEVICE_FORM_TITLE #language en-US ""
 #string STR_IP4_DEVICE_FORM_HELP  #language en-US ""
 #string STR_IP4_CONFIGURE #language en-US "Configured"
+#string STR_IP4_CONFIGURE_HELP#language en-US "Indicate whether 
network address configured successfully or not."
 #string STR_IP4_ENABLE_DHCP   #language en-US "Enable DHCP"
 #string STR_IP4_LOCAL_IP_ADDRESS  #language en-US "Local IP Address"
 #string STR_IP4_IP_ADDRESS_HELP   #language en-US "Enter IP address in 
dotted-decimal notation. Example: 192.168.10.12\r\n"
 #string STR_IP4_LOCAL_MASK#language en-US "Local NetMask"
 #string STR_IP4_MASK_HELP #language en-US "Enter NetMask in 
dotted-decimal notation. Example: 255.255.255.0\r\n"
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] NetworkPkg: Fix PXEv6 boot failure when DhcpBinl offer received.

2017-04-26 Thread Jiaxin Wu
In case of the DHCP and PXE services on different servers,PXEv6 boot will
failure when DhcpBinl offer received. The issue is caused by the following
reasons:
* PXE Client doesn't append VENDOR_CLASS request parameter, so the
offer replied from DHCP service will not contain VENDOR_CLASS option
(16).
* Once the DhcpBinl offer is selected, the boot discover message should
be sent out to request the bootfile by this offer. Current implementation
always use servers multi-cast address instead of BootFileUrl address in
dhcp6 offer. we should check it first, then decide whether use multi-cast
address or not.
* If DhcpBinl offer is selected, the boot discover message shouldn't
find server ID Option from DhcpBinl offer. That's incorrect because DHCP
service and PXE service on different servers. In such a case, we can ignore
the Server ID Option.

With the above fix in the patch, PXEv6 can boot successfully when DhcpBinl
offer received.

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c | 43 +++-
 1 file changed, 23 insertions(+), 20 deletions(-)

diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c 
b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
index 4cd1770..f2239fd 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
@@ -91,15 +91,16 @@ PxeBcBuildDhcp6Options (
 
   //
   // Append client option request option
   //
   OptList[Index]->OpCode = HTONS (DHCP6_OPT_ORO);
-  OptList[Index]->OpLen  = HTONS (6);
+  OptList[Index]->OpLen  = HTONS (8);
   OptEnt.Oro = (PXEBC_DHCP6_OPTION_ORO *) OptList[Index]->Data;
   OptEnt.Oro->OpCode[0]  = HTONS(DHCP6_OPT_BOOT_FILE_URL);
   OptEnt.Oro->OpCode[1]  = HTONS(DHCP6_OPT_BOOT_FILE_PARAM);
   OptEnt.Oro->OpCode[2]  = HTONS(DHCP6_OPT_DNS_SERVERS);
+  OptEnt.Oro->OpCode[3]  = HTONS(DHCP6_OPT_VENDOR_CLASS);
   Index++;
   OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
 
   //
   // Append client network device interface option
@@ -905,16 +906,16 @@ PxeBcRequestBootService (
   UINTN   ReadSize;
   UINT16  OpFlags;
   UINT16  OpCode;
   UINT16  OpLen;
   EFI_STATUS  Status;
-  EFI_DHCP6_PACKET*ProxyOffer;
+  EFI_DHCP6_PACKET*IndexOffer;
   UINT8   *Option;
 
   PxeBc   = &Private->PxeBc;
   Request = Private->Dhcp6Request;
-  ProxyOffer = &Private->OfferBuffer[Index].Dhcp6.Packet.Offer;
+  IndexOffer  = &Private->OfferBuffer[Index].Dhcp6.Packet.Offer;
   SrcPort = PXEBC_BS_DISCOVER_PORT;
   DestPort= PXEBC_BS_DISCOVER_PORT;
   OpFlags = 0;
 
   if (Request == NULL) {
@@ -927,36 +928,38 @@ PxeBcRequestBootService (
   }
 
   //
   // Build the request packet by the cached request packet before.
   //
-  Discover->TransactionId = ProxyOffer->Dhcp6.Header.TransactionId;
+  Discover->TransactionId = IndexOffer->Dhcp6.Header.TransactionId;
   Discover->MessageType   = Request->Dhcp6.Header.MessageType;
   RequestOpt  = Request->Dhcp6.Option;
   DiscoverOpt = Discover->DhcpOptions;
   DiscoverLen = sizeof (EFI_DHCP6_HEADER);
   RequestLen  = DiscoverLen;
 
   //
   // Find Server ID Option from ProxyOffer.
   //
-  Option = PxeBcDhcp6SeekOption (
- ProxyOffer->Dhcp6.Option,
- ProxyOffer->Length - 4,
- DHCP6_OPT_SERVER_ID
- );
-  if (Option == NULL) {
-return EFI_NOT_FOUND;
-  }
+  if (Private->OfferBuffer[Index].Dhcp6.OfferType == PxeOfferTypeProxyBinl) {  
+Option = PxeBcDhcp6SeekOption (
+   IndexOffer->Dhcp6.Option,
+   IndexOffer->Length - 4,
+   DHCP6_OPT_SERVER_ID
+   );
+if (Option == NULL) {
+  return EFI_NOT_FOUND;
+}
   
-  //
-  // Add Server ID Option.
-  //
-  OpLen = NTOHS (((EFI_DHCP6_PACKET_OPTION *) Option)->OpLen);
-  CopyMem (DiscoverOpt, Option, OpLen + 4);
-  DiscoverOpt += (OpLen + 4);
-  DiscoverLen += (OpLen + 4);
+//
+// Add Server ID Option.
+//
+OpLen = NTOHS (((EFI_DHCP6_PACKET_OPTION *) Option)->OpLen);
+CopyMem (DiscoverOpt, Option, OpLen + 4);
+DiscoverOpt += (OpLen + 4);
+DiscoverLen += (OpLen + 4);
+  }
 
   while (RequestLen < Request->Length) {
 OpCode = NTOHS (((EFI_DHCP6_PACKET_OPTION *) RequestOpt)->OpCode);
 OpLen  = NTOHS (((EFI_DHCP6_PACKET_OPTION *) RequestOpt)->OpLen);
 if (OpCode != EFI_DHCP6_IA_TYPE_NA &&
@@ -1076,11 +1079,11 @@ PxeBcRetryDhcp6Binl (
   Private->OfferBuffer[Index].Dhcp6.OfferType == 
PxeOfferTypeProxyBinl);
 
   Mode  = Private->PxeBc.Mode;
   Private->IsDoDiscover = FALSE;
   Offer = &Private->OfferBuffer[Index].Dhcp6;
-  if (Offer->Offe

[edk2] [Patch] Nt32Pkg/SnpNt32Dxe: Fix hang issue when multiple network interfaces existed

2017-05-04 Thread Jiaxin Wu
Currently all the network interfaces share the one recycled transmit buffer
array, which is used to store the recycled buffer address. However, those
recycled buffers are allocated by the different MNP interface if the multiple
network interfaces existed. Then, SNP GetStatus may return one recycled transmit
buffer address to the another MNP interface, which may result in the MNP driver
hang after 'reconnect -r' operation.

Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 Nt32Pkg/SnpNt32Dxe/SnpNt32.c | 50 ++--
 Nt32Pkg/SnpNt32Dxe/SnpNt32.h | 31 ++-
 2 files changed, 41 insertions(+), 40 deletions(-)

diff --git a/Nt32Pkg/SnpNt32Dxe/SnpNt32.c b/Nt32Pkg/SnpNt32Dxe/SnpNt32.c
index 9018800..c1ef324 100644
--- a/Nt32Pkg/SnpNt32Dxe/SnpNt32.c
+++ b/Nt32Pkg/SnpNt32Dxe/SnpNt32.c
@@ -1,8 +1,8 @@
 /** @file
 
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -42,13 +42,10 @@ SNPNT32_GLOBAL_DATA gSnpNt32GlobalData = {
   {
 0,
 0,
 EfiLockUninitialized
   },  //  Lock
-  NULL,   //  RecycledTxBuf
-  0,  //  RecycledTxBufCount
-  32, //  MaxRecycledTxBuf
   //
   //  Private functions
   //
   SnpNt32InitializeGlobalData,//  InitializeGlobalData
   SnpNt32InitializeInstanceData,  //  InitializeInstanceData
@@ -394,10 +391,13 @@ SNPNT32_INSTANCE_DATA gSnpNt32InstanceTemplate = {
   SNP_NT32_INSTANCE_SIGNATURE,//  Signature
   {
 NULL,
 NULL
   },  //  Entry
+  NULL,   //  RecycledTxBuf
+  0,  //  RecycledTxBufCount
+  32, //  MaxRecycledTxBuf
   NULL,   //  GlobalData
   NULL,   //  DeviceHandle
   NULL,   //  DevicePath
   {   //  Snp
 EFI_SIMPLE_NETWORK_PROTOCOL_REVISION, //  Revision
@@ -863,20 +863,17 @@ SnpNt32GetStatus (
   OUT UINT32 *InterruptStatus,
   OUT VOID   **TxBuffer
   )
 {
   SNPNT32_INSTANCE_DATA *Instance;
-  SNPNT32_GLOBAL_DATA   *GlobalData;
 
   Instance= SNP_NT32_INSTANCE_DATA_FROM_SNP_THIS (This);
 
-  GlobalData  = Instance->GlobalData;
-
   if (TxBuffer != NULL) {
-if (GlobalData->RecycledTxBufCount != 0) {
-  GlobalData->RecycledTxBufCount --;
-  *((UINT8 **) TxBuffer)= (UINT8 *) 
(UINTN)GlobalData->RecycledTxBuf[GlobalData->RecycledTxBufCount];
+if (Instance->RecycledTxBufCount != 0) {
+  Instance->RecycledTxBufCount --;
+  *((UINT8 **) TxBuffer)= (UINT8 *) 
(UINTN)Instance->RecycledTxBuf[Instance->RecycledTxBufCount];
 } else {
   *((UINT8 **) TxBuffer)= NULL;
 }
   }
 
@@ -959,26 +956,26 @@ SnpNt32Transmit (
   EfiReleaseLock (&GlobalData->Lock);
 
   if (ReturnValue < 0) {
 return EFI_DEVICE_ERROR;
   } else {
-if ((GlobalData->MaxRecycledTxBuf + SNP_TX_BUFFER_INCREASEMENT) >= 
SNP_MAX_TX_BUFFER_NUM) {
+if ((Instance->MaxRecycledTxBuf + SNP_TX_BUFFER_INCREASEMENT) >= 
SNP_MAX_TX_BUFFER_NUM) {
   return EFI_NOT_READY;
 }
 
-if (GlobalData->RecycledTxBufCount < GlobalData->MaxRecycledTxBuf) {
-  GlobalData->RecycledTxBuf[GlobalData->RecycledTxBufCount] = (UINT64) 
Buffer;
-  GlobalData->RecycledTxBufCount ++;
+if (Instance->RecycledTxBufCount < Instance->MaxRecycledTxBuf) {
+  Instance->RecycledTxBuf[Instance->RecycledTxBufCount] = (UINT64) Buffer;
+  Instance->RecycledTxBufCount ++;
 } else {
-  Tmp = AllocatePool (sizeof (UINT64) * (GlobalData->MaxRecycledTxBuf + 
SNP_TX_BUFFER_INCREASEMENT));
+  Tmp = AllocatePool (sizeof (UINT64) * (Instance->MaxRecycledTxBuf + 
SNP_TX_BUFFER_INCREASEMENT));
   if (Tmp == NULL) {
 return EFI_DEVICE_ERROR;
   }
-  CopyMem (Tmp, GlobalData->RecycledTxBuf, sizeof (UINT64) * 
GlobalData->RecycledTxBufCount);
-  FreePool (GlobalData->RecycledTxBuf);
-  GlobalData->RecycledTxBuf=  Tmp;
-  GlobalData->MaxRecycledTxBuf += SNP_TX_BUFFER_INCREASEMENT;
+  CopyMem (Tmp, Instance->RecycledTxBuf, sizeof (UINT64) * 
Instance->RecycledTxBufCount);
+  FreePool (Instance->RecycledTxBuf);
+  Instance->RecycledTxBuf=  Tmp;
+  Instance->MaxRecycledTxBuf += SNP_TX_BUFFER_INCREASEMENT;
 }
   }
 
   return EFI_SUCCESS;
 }
@@ -1114,15 +,10 @@ SnpNt32InitializeGlob

[edk2] [Patch] NetworkPkg/IScsiDxe: Switch IP4 configuration policy to Static before DHCP

2017-05-10 Thread Jiaxin Wu
DHCP4 service allows only one of its children to be configured in the active
state. If the DHCP4 D.O.R.A started by IP4 auto configuration and has not
been completed, the Dhcp4 state machine will not be in the right state for
the iSCSI to start a new round D.O.R.A. So, we need to switch it's policy to
static.

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/IScsiDxe/IScsiDhcp.c | 61 +
 1 file changed, 61 insertions(+)

diff --git a/NetworkPkg/IScsiDxe/IScsiDhcp.c b/NetworkPkg/IScsiDxe/IScsiDhcp.c
index 43ae50b..6587a05 100644
--- a/NetworkPkg/IScsiDxe/IScsiDhcp.c
+++ b/NetworkPkg/IScsiDxe/IScsiDhcp.c
@@ -369,10 +369,54 @@ IScsiParseDhcpAck (
   FreePool (OptionList);
 
   return Status;
 }
 
+/**
+  This function will switch the IP4 configuration policy to Static.
+
+  @param[in]  Ip4Config2  Pointer to the IP4 configuration protocol.
+
+  @retval EFI_SUCCESS The policy is already configured to static.
+  @retval Others  Other error as indicated.
+
+**/
+EFI_STATUS
+IScsiSetIp4Policy (
+  IN EFI_IP4_CONFIG2_PROTOCOL*Ip4Config2
+  )
+{
+  EFI_IP4_CONFIG2_POLICY  Policy;
+  EFI_STATUS  Status;
+  UINTN   DataSize;
+
+  DataSize = sizeof (EFI_IP4_CONFIG2_POLICY);
+  Status = Ip4Config2->GetData (
+ Ip4Config2,
+ Ip4Config2DataTypePolicy,
+ &DataSize,
+ &Policy
+ );
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+
+  if (Policy != Ip4Config2PolicyStatic) {
+Policy = Ip4Config2PolicyStatic;
+Status= Ip4Config2->SetData (
+  Ip4Config2,
+  Ip4Config2DataTypePolicy,
+  sizeof (EFI_IP4_CONFIG2_POLICY),
+  &Policy
+  );
+if (EFI_ERROR (Status)) {
+  return Status;
+} 
+  }
+
+  return EFI_SUCCESS;
+}
 
 /**
   Parse the DHCP ACK to get the address configuration and DNS information.
 
   @param[in]   ImageThe handle of the driver image.
@@ -391,18 +435,20 @@ IScsiDoDhcp (
   IN EFI_HANDLE  Controller,
   IN OUT ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData
   )
 {
   EFI_HANDLEDhcp4Handle;
+  EFI_IP4_CONFIG2_PROTOCOL  *Ip4Config2;
   EFI_DHCP4_PROTOCOL*Dhcp4;
   EFI_STATUSStatus;
   EFI_DHCP4_PACKET_OPTION   *ParaList;
   EFI_DHCP4_CONFIG_DATA Dhcp4ConfigData;
   ISCSI_SESSION_CONFIG_NVDATA   *NvData;
   BOOLEAN   MediaPresent;
 
   Dhcp4Handle = NULL;
+  Ip4Config2  = NULL;
   Dhcp4   = NULL;
   ParaList= NULL;
 
   //
   // Check media status before doing DHCP.
@@ -412,10 +458,25 @@ IScsiDoDhcp (
   if (!MediaPresent) {
 return EFI_NO_MEDIA;
   }
 
   //
+  // DHCP4 service allows only one of its children to be configured in  
+  // the active state, If the DHCP4 D.O.R.A started by IP4 auto  
+  // configuration and has not been completed, the Dhcp4 state machine 
+  // will not be in the right state for the iSCSI to start a new round 
D.O.R.A. 
+  // So, we need to switch it's policy to static.
+  //
+  Status = gBS->HandleProtocol (Controller, &gEfiIp4Config2ProtocolGuid, (VOID 
**) &Ip4Config2);
+  if (!EFI_ERROR (Status)) {
+Status = IScsiSetIp4Policy (Ip4Config2);
+if (EFI_ERROR (Status)) {
+  return Status;
+}
+  }
+
+  //
   // Create a DHCP4 child instance and get the protocol.
   //
   Status = NetLibCreateServiceChild (
  Controller,
  Image,
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 1/2] MdeModulePkg/UefiPxeBcDxe: Fix the PXE BootMenu selection issue

2017-05-22 Thread Jiaxin Wu
Currently implementation doesn't accept the input during the user
is trying to select the PXE BootMenu from option 43. This path is
to fix that problem.

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c 
b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c
index f0720e5..c5f3437 100644
--- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c
+++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c
@@ -1,10 +1,10 @@
 /** @file
   Support for PxeBc dhcp functions.
 
 Copyright (c) 2013, Red Hat, Inc.
-Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -1843,11 +1843,11 @@ PxeBcSelectBootMenu (
   CHAR8  Blank[70];
   PXEBC_BOOT_MENU_ENTRY  *MenuItem;
   PXEBC_BOOT_MENU_ENTRY  *MenuArray[PXEBC_MAX_MENU_NUM];
 
   Finish  = FALSE;
-  Select  = 1;
+  Select  = 0;
   Index   = 0;
   *Type   = 0;
 
   if (Private->PxeBc.Mode->ProxyOfferReceived) {
 
@@ -1912,11 +1912,11 @@ PxeBcSelectBootMenu (
 
 while (gST->ConIn->ReadKeyStroke (gST->ConIn, &InputKey) == EFI_NOT_READY) 
{
   gBS->Stall (10 * TICKS_PER_MS);
 }
 
-if (InputKey.ScanCode != 0) {
+if (InputKey.ScanCode == 0) {
   switch (InputKey.UnicodeChar) {
   case CTRL ('c'):
 InputKey.ScanCode = SCAN_ESC;
 break;
 
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 0/2] Fix the issue in MdeModulePkg/UefiPxeBcDxe

2017-05-22 Thread Jiaxin Wu
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 

Jiaxin Wu (2):
  MdeModulePkg/UefiPxeBcDxe: Fix the PXE BootMenu selection issue
  MdeModulePkg/UefiPxeBcDxe: Refine the PXE boot displayed information

 .../Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c |  6 +++---
 .../Universal/Network/UefiPxeBcDxe/PxeBcImpl.c | 18 ++
 .../Universal/Network/UefiPxeBcDxe/PxeBcSupport.c  | 22 +-
 .../Universal/Network/UefiPxeBcDxe/PxeBcSupport.h  | 16 +++-
 4 files changed, 57 insertions(+), 5 deletions(-)

-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 2/2] MdeModulePkg/UefiPxeBcDxe: Refine the PXE boot displayed information

2017-05-22 Thread Jiaxin Wu
This path is to refine the PXE boot displayed information so as to
in line with NetworkPkg/UefiPxeBcDxe driver.

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 .../Universal/Network/UefiPxeBcDxe/PxeBcImpl.c | 18 ++
 .../Universal/Network/UefiPxeBcDxe/PxeBcSupport.c  | 22 +-
 .../Universal/Network/UefiPxeBcDxe/PxeBcSupport.h  | 16 +++-
 3 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c 
b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
index 259568e..6d4f33f 100644
--- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
+++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
@@ -336,10 +336,12 @@ EfiPxeBcStart (
 // IPv6 is not supported now.
 //
 return EFI_UNSUPPORTED;
   }
 
+  AsciiPrint ("\n>>Start PXE over IPv4");
+
   //
   // Configure the udp4 instance to let it receive data
   //
   Status = Private->Udp4Read->Configure (
Private->Udp4Read,
@@ -665,10 +667,15 @@ EfiPxeBcDhcp (
   // Check the selected offer to see whether BINL is required, if no or BINL is
   // finished, set the various Mode members.
   //
   Status = PxeBcCheckSelectedOffer (Private);
 
+  AsciiPrint ("\n  Station IP address is ");
+
+  PxeBcShowIp4Addr (&Private->StationIp.v4);
+  AsciiPrint ("\n");
+
 ON_EXIT:
   if (EFI_ERROR (Status)) {
 Dhcp4->Stop (Dhcp4);
 Dhcp4->Configure (Dhcp4, NULL);
   } else {
@@ -2738,10 +2745,18 @@ DiscoverBootFile (
   );
   }
 
   Private->FileSize = (UINTN) *BufferSize;
 
+  //
+  // Display all the information: boot server address, boot file name and boot 
file size.
+  //
+  AsciiPrint ("\n  Server IP address is ");
+  PxeBcShowIp4Addr (&Private->ServerIp.v4);
+  AsciiPrint ("\n  NBP filename is %a", Private->BootFileName);
+  AsciiPrint ("\n  NBP filesize is %d Bytes", Private->FileSize);
+
   return Status;
 }
 
 /**
   Causes the driver to load a specified file.
@@ -2853,10 +2868,11 @@ EfiPxeLoadFile (
 Status  = DiscoverBootFile (Private, &TmpBufSize, Buffer);
 
 if (sizeof (UINTN) < sizeof (UINT64) && (TmpBufSize > 0x)) {
   Status = EFI_DEVICE_ERROR;
 } else if (TmpBufSize > 0 && *BufferSize >= (UINTN) TmpBufSize && Buffer 
!= NULL) {
+  AsciiPrint ("\n Downloading NBP file...\n");
   *BufferSize = (UINTN) TmpBufSize;
   Status = PxeBc->Mtftp (
 PxeBc,
 EFI_PXE_BASE_CODE_TFTP_READ_FILE,
 Buffer,
@@ -2877,10 +2893,11 @@ EfiPxeLoadFile (
 Status  = EFI_BUFFER_TOO_SMALL;
   } else {
 //
 // Download the file.
 //
+AsciiPrint ("\n Downloading NBP file...\n");
 TmpBufSize = (UINT64) (*BufferSize);
 Status = PxeBc->Mtftp (
   PxeBc,
   EFI_PXE_BASE_CODE_TFTP_READ_FILE,
   Buffer,
@@ -2911,10 +2928,11 @@ EfiPxeLoadFile (
 
   //
   // Check download status
   //
   if (Status == EFI_SUCCESS) {
+AsciiPrint ("\n  NBP file downloaded successfully.\n");
 //
 // The DHCP4 can have only one configured child instance so we need to stop
 // reset the DHCP4 child before we return. Otherwise the other programs 
which 
 // also need to use DHCP4 will be impacted.
 // The functionality of PXE Base Code protocol will not be stopped,
diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c 
b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c
index 0779056..c1cabca 100644
--- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c
+++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c
@@ -1,9 +1,9 @@
 /** @file
   Support routines for PxeBc.
 
-Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -112,10 +112,30 @@ PxeBcConfigureUdpWriteInstance (
   }
 
   return Status;
 }
 
+/**
+  This function is to display the IPv4 address.
+
+  @param[in]  IpThe pointer to the IPv4 address.
+
+**/
+VOID
+PxeBcShowIp4Addr (
+  IN EFI_IPv4_ADDRESS   *Ip
+  )
+{
+  UINTN Index;
+
+  for (Index = 0; Index < 4; Index++) {
+AsciiPrint ("%d", Ip->Addr[Index]);
+if (Index < 3) {
+  AsciiPrint (".");
+}
+  }
+}
 
 /**
   Convert number to ASCII value.
 
   @param  Number  Numeric value to convert to decimal ASCII value.
diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.h 
b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.h
index 16ac05e..59e9b32 100644
--- a/MdeModul

[edk2] [Patch 2/2] NetworkPkg: Typo fix and comments correction

2017-06-12 Thread Jiaxin Wu
warter -> water
Maunual -> Manual
TCP and UDP --> TCP4 and TCP6
TCP or UDP --> TCP4 or TCP6

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c |  6 +++---
 NetworkPkg/TcpDxe/Socket.h| 10 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c 
b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
index 7575b79..7c7acc7 100644
--- a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
+++ b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
@@ -754,11 +754,11 @@ Ip6ConfigSetDadXmits (
 }
 
 /**
   The callback function for Ip6SetAddr. The prototype is defined
   as IP6_DAD_CALLBACK. It is called after Duplicate Address Detection is 
performed
-  for the manual address set by Ip6ConfigSetMaunualAddress.
+  for the manual address set by Ip6ConfigSetManualAddress.
 
   @param[in] IsDadPassed   If TRUE, Duplicate Address Detection passed.
   @param[in] TargetAddress The tentative IPv6 address to be checked.
   @param[in] Context   Pointer to the IP6 configuration instance data.
 
@@ -894,11 +894,11 @@ Ip6ManualAddrDadCallback (
   @retval EFI_SUCCESS   The specified configuration data for the EFI 
IPv6
 network stack was set.
 
 **/
 EFI_STATUS
-Ip6ConfigSetMaunualAddress (
+Ip6ConfigSetManualAddress (
   IN IP6_CONFIG_INSTANCE  *Instance,
   IN UINTNDataSize,
   IN VOID *Data
   )
 {
@@ -2216,11 +2216,11 @@ Ip6ConfigInitInstance (
   DataItem->DataSize = sizeof (Instance->DadXmits);
   Instance->DadXmits.DupAddrDetectTransmits = IP6_CONFIG_DEFAULT_DAD_XMITS;
   SET_DATA_ATTRIB (DataItem->Attribute, DATA_ATTRIB_SIZE_FIXED);
 
   DataItem   = &Instance->DataItem[Ip6ConfigDataTypeManualAddress];
-  DataItem->SetData  = Ip6ConfigSetMaunualAddress;
+  DataItem->SetData  = Ip6ConfigSetManualAddress;
   DataItem->Status   = EFI_NOT_FOUND;
 
   DataItem   = &Instance->DataItem[Ip6ConfigDataTypeGateway];
   DataItem->SetData  = Ip6ConfigSetGateway;
   DataItem->Status   = EFI_NOT_FOUND;
diff --git a/NetworkPkg/TcpDxe/Socket.h b/NetworkPkg/TcpDxe/Socket.h
index 371e9ab..f7f4a7a 100644
--- a/NetworkPkg/TcpDxe/Socket.h
+++ b/NetworkPkg/TcpDxe/Socket.h
@@ -359,11 +359,11 @@ typedef enum {
 ///
 ///  The buffer structure of rcvd data and send data used by socket.
 ///
 typedef struct _SOCK_BUFFER {
   UINT32HighWater;  ///< The buffersize upper limit of sock_buffer
-  UINT32LowWater;   ///< The low warter mark of sock_buffer
+  UINT32LowWater;   ///< The low water mark of sock_buffer
   NET_BUF_QUEUE *DataQueue; ///< The queue to buffer data
 } SOCK_BUFFER;
 
 /**
   The handler of protocol for request from socket.
@@ -423,12 +423,12 @@ typedef struct _SOCK_INIT_DATA {
   SOCK_TYPE  Type;
   UINT8  State;
 
   SOCKET *Parent;///< The parent of this socket
   UINT32 BackLog;///< The connection limit for 
listening socket
-  UINT32 SndBufferSize;  ///< The high warter mark of send 
buffer
-  UINT32 RcvBufferSize;  ///< The high warter mark of receive 
buffer
+  UINT32 SndBufferSize;  ///< The high water mark of send 
buffer
+  UINT32 RcvBufferSize;  ///< The high water mark of receive 
buffer
   UINT8  IpVersion;
   VOID   *Protocol;  ///< The pointer to protocol function 
template
  ///< wanted to install on socket
 
   //
@@ -448,11 +448,11 @@ typedef struct _SOCK_INIT_DATA {
 
   EFI_HANDLE DriverBinding;   ///< The driver binding handle
 } SOCK_INIT_DATA;
 
 ///
-///  The union type of TCP and UDP protocol.
+///  The union type of TCP4 and TCP6 protocol.
 ///
 typedef union _NET_PROTOCOL {
   EFI_TCP4_PROTOCOL  Tcp4Protocol;///< Tcp4 protocol
   EFI_TCP6_PROTOCOL  Tcp6Protocol;///< Tcp6 protocol
 } NET_PROTOCOL;
@@ -500,11 +500,11 @@ struct _TCP_SOCKET {
   // Interface for low level protocol
   //
   SOCK_PROTO_HANDLERProtoHandler; ///< The request handler of 
protocol
   UINT8 ProtoReserved[PROTO_RESERVED_LEN];  ///< Data 
fields reserved for protocol
   UINT8 IpVersion;
-  NET_PROTOCOL  NetProtocol;///< TCP or 
UDP protocol socket used
+  NET_PROTOCOL  NetProtocol;///< TCP4 or 
TCP6 protocol socket used
   //
   // Callbacks after socket is created and before socket is to be destroyed.
   //
   SOCK_CREATE_CALLBACK  CreateCallback;   ///< Callback after created
   SOCK_DESTROY_CALLBACK DestroyCallback;  ///< Callback before destroied
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 0/2] Typo fix and comments correction

2017-06-12 Thread Jiaxin Wu
warter -> water
Maunual -> Manual
TCP and UDP --> TCP4 and TCP6
TCP or UDP --> TCP4 or TCP6

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 

Jiaxin Wu (2):
  MdeModulePkg/Network: Typo fix
  NetworkPkg: Typo fix and comments correction

 MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c |  4 ++--
 MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h|  6 +++---
 NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c  |  6 +++---
 NetworkPkg/TcpDxe/Socket.h | 10 +-
 4 files changed, 13 insertions(+), 13 deletions(-)

-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 1/2] MdeModulePkg/Network: Typo fix

2017-06-12 Thread Jiaxin Wu
warter -> water
Maunual -> Manual

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c | 4 ++--
 MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h| 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c 
b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
index f4dfbb6..3e38085 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
@@ -1226,11 +1226,11 @@ Ip4Config2SetPolicy (
   @retval EFI_SUCCESS   The specified configuration data for the EFI 
IPv6
 network stack was set.
 
 **/
 EFI_STATUS
-Ip4Config2SetMaunualAddress (
+Ip4Config2SetManualAddress (
   IN IP4_CONFIG2_INSTANCE *Instance,
   IN UINTNDataSize,
   IN VOID *Data
   )
 {
@@ -1926,11 +1926,11 @@ Ip4Config2InitInstance (
   DataItem->DataSize = sizeof (Instance->Policy);
   Instance->Policy   = Ip4Config2PolicyStatic;
   SET_DATA_ATTRIB (DataItem->Attribute, DATA_ATTRIB_SIZE_FIXED);
 
   DataItem   = &Instance->DataItem[Ip4Config2DataTypeManualAddress];
-  DataItem->SetData  = Ip4Config2SetMaunualAddress;
+  DataItem->SetData  = Ip4Config2SetManualAddress;
   DataItem->Status   = EFI_NOT_FOUND;
 
   DataItem   = &Instance->DataItem[Ip4Config2DataTypeGateway];
   DataItem->SetData  = Ip4Config2SetGateway;
   DataItem->Status   = EFI_NOT_FOUND;
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h 
b/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h
index 8c25c63..9c2e6d0 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h
@@ -371,11 +371,11 @@ typedef enum {
 ///
 ///  The buffer structure of rcvd data and send data used by socket.
 ///
 typedef struct _SOCK_BUFFER {
   UINT32HighWater;  ///< The buffersize upper limit of sock_buffer
-  UINT32LowWater;   ///< The low warter mark of sock_buffer
+  UINT32LowWater;   ///< The low water mark of sock_buffer
   NET_BUF_QUEUE *DataQueue; ///< The queue to buffer data
 } SOCK_BUFFER;
 
 /**
   The handler of protocol for request from socket.
@@ -591,12 +591,12 @@ typedef struct _SOCK_INIT_DATA {
   SOCK_TYPE   Type;
   UINT8   State;
 
   SOCKET  *Parent;///< The parent of this socket
   UINT32  BackLog;///< The connection limit for listening socket
-  UINT32  SndBufferSize;  ///< The high warter mark of send buffer
-  UINT32  RcvBufferSize;  ///< The high warter mark of receive buffer
+  UINT32  SndBufferSize;  ///< The high water mark of send buffer
+  UINT32  RcvBufferSize;  ///< The high water mark of receive buffer
   VOID*Protocol;  ///< The pointer to protocol function template
   ///< wanted to install on socket
 
   //
   // Callbacks after socket is created and before socket is to be destroyed.
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 0/2] Clarify the usage of HttpConfigData in HTTP protocol

2017-09-27 Thread Jiaxin Wu
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 

Jiaxin Wu (2):
  MdePkg/Http.h: Clarify the usage of HttpConfigData in HTTP protocol
  NetworkPkg/HttpDxe: Clarify the usage of HttpConfigData in HTTP
protocol

 MdePkg/Include/Protocol/Http.h | 16 +---
 NetworkPkg/HttpDxe/HttpImpl.c  | 20 +++-
 NetworkPkg/HttpDxe/HttpImpl.h  | 18 ++
 3 files changed, 30 insertions(+), 24 deletions(-)

-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 1/2] MdePkg/Http.h: Clarify the usage of HttpConfigData in HTTP protocol

2017-09-27 Thread Jiaxin Wu
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdePkg/Include/Protocol/Http.h | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/MdePkg/Include/Protocol/Http.h b/MdePkg/Include/Protocol/Http.h
index 297d9c3..bdcd7b1 100644
--- a/MdePkg/Include/Protocol/Http.h
+++ b/MdePkg/Include/Protocol/Http.h
@@ -303,19 +303,21 @@ typedef struct {
   The GetModeData() function is used to read the current mode data (operational
   parameters) for this HTTP protocol instance.
 
   @param[in]  ThisPointer to EFI_HTTP_PROTOCOL instance.
   @param[out] HttpConfigData  Point to buffer for operational parameters 
of this
-  HTTP instance.
+  HTTP instance. It is the responsibility of 
the caller 
+  to allocate the memory for HttpConfigData 
and 
+  
HttpConfigData->AccessPoint.IPv6Node/IPv4Node. In fact, 
+  it is recommended to allocate sufficient 
memory to record 
+  IPv6Node since it is big enough for all 
possibilities.
 
   @retval EFI_SUCCESS Operation succeeded.
   @retval EFI_INVALID_PARAMETER   This is NULL.
   HttpConfigData is NULL.
-  HttpInstance->LocalAddressIsIPv6 is FALSE and
-  HttpConfigData->IPv4Node is NULL.
-  HttpInstance->LocalAddressIsIPv6 is TRUE and
-  HttpConfigData->IPv6Node is NULL.
+  HttpConfigData->AccessPoint.IPv4Node or 
+  HttpConfigData->AccessPoint.IPv6Node is NULL.
   @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been 
started.
 **/
 typedef
 EFI_STATUS
 (EFIAPI *EFI_HTTP_GET_MODE_DATA)(
@@ -341,13 +343,13 @@ EFI_STATUS
 
   @retval EFI_SUCCESS Operation succeeded.
   @retval EFI_INVALID_PARAMETER   One or more of the following conditions is 
TRUE:
   This is NULL.
   HttpConfigData->LocalAddressIsIPv6 is FALSE 
and
-  HttpConfigData->IPv4Node is NULL.
+  HttpConfigData->AccessPoint.IPv4Node is NULL.
   HttpConfigData->LocalAddressIsIPv6 is TRUE 
and
-  HttpConfigData->IPv6Node is NULL.
+  HttpConfigData->AccessPoint.IPv6Node is NULL.
   @retval EFI_ALREADY_STARTED Reinitialize this HTTP instance without 
calling
   Configure() with NULL to reset it.
   @retval EFI_DEVICE_ERRORAn unexpected system or network error 
occurred.
   @retval EFI_OUT_OF_RESOURCESCould not allocate enough system resources 
when
   executing Configure().
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 2/2] NetworkPkg/HttpDxe: Clarify the usage of HttpConfigData in HTTP protocol

2017-09-27 Thread Jiaxin Wu
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/HttpDxe/HttpImpl.c | 20 +++-
 NetworkPkg/HttpDxe/HttpImpl.h | 18 ++
 2 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
index c104b61..46d0323 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.c
+++ b/NetworkPkg/HttpDxe/HttpImpl.c
@@ -31,20 +31,22 @@ EFI_HTTP_PROTOCOL  mEfiHttpTemplate = {
   The GetModeData() function is used to read the current mode data (operational
   parameters) for this HTTP protocol instance.
 
   @param[in]  ThisPointer to EFI_HTTP_PROTOCOL instance.
   @param[out] HttpConfigData  Point to buffer for operational parameters 
of this
-  HTTP instance.
+  HTTP instance. It is the responsibility of 
the caller 
+  to allocate the memory for HttpConfigData 
and 
+  
HttpConfigData->AccessPoint.IPv6Node/IPv4Node. In fact, 
+  it is recommended to allocate sufficient 
memory to record 
+  IPv6Node since it is big enough for all 
possibilities. 
 
   @retval EFI_SUCCESS Operation succeeded.
   @retval EFI_INVALID_PARAMETER   One or more of the following conditions is 
TRUE:
   This is NULL.
   HttpConfigData is NULL.
-  HttpInstance->LocalAddressIsIPv6 is FALSE and
-  HttpConfigData->IPv4Node is NULL.
-  HttpInstance->LocalAddressIsIPv6 is TRUE and
-  HttpConfigData->IPv6Node is NULL.
+  HttpConfigData->AccessPoint.IPv4Node or 
+  HttpConfigData->AccessPoint.IPv6Node is NULL.
   @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been 
started.
 
 **/
 EFI_STATUS
 EFIAPI
@@ -63,12 +65,12 @@ EfiHttpGetModeData (
   }
 
   HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (This);
   ASSERT (HttpInstance != NULL);
 
-  if ((HttpInstance->LocalAddressIsIPv6 && 
HttpConfigData->AccessPoint.IPv6Node == NULL) ||
-  (!HttpInstance->LocalAddressIsIPv6 && 
HttpConfigData->AccessPoint.IPv4Node == NULL)) {
+  if ((HttpConfigData->AccessPoint.IPv6Node == NULL) ||
+  (HttpConfigData->AccessPoint.IPv4Node == NULL)) {
 return EFI_INVALID_PARAMETER;
   }
 
   if (HttpInstance->State < HTTP_STATE_HTTP_CONFIGED) {
 return EFI_NOT_STARTED;
@@ -113,13 +115,13 @@ EfiHttpGetModeData (
 
   @retval EFI_SUCCESS Operation succeeded.
   @retval EFI_INVALID_PARAMETER   One or more of the following conditions is 
TRUE:
   This is NULL.
   HttpConfigData->LocalAddressIsIPv6 is FALSE 
and
-  HttpConfigData->IPv4Node is NULL.
+  HttpConfigData->AccessPoint.IPv4Node is NULL.
   HttpConfigData->LocalAddressIsIPv6 is TRUE 
and
-  HttpConfigData->IPv6Node is NULL.
+  HttpConfigData->AccessPoint.IPv6Node is NULL.
   @retval EFI_ALREADY_STARTED Reinitialize this HTTP instance without 
calling
   Configure() with NULL to reset it.
   @retval EFI_DEVICE_ERRORAn unexpected system or network error 
occurred.
   @retval EFI_OUT_OF_RESOURCESCould not allocate enough system resources 
when
   executing Configure().
diff --git a/NetworkPkg/HttpDxe/HttpImpl.h b/NetworkPkg/HttpDxe/HttpImpl.h
index 40b2504..6550ce0 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.h
+++ b/NetworkPkg/HttpDxe/HttpImpl.h
@@ -1,9 +1,9 @@
 /** @file
   The header files of implementation of EFI_HTTP_PROTOCOL protocol interfaces.
 
-  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
   (C) Copyright 2016 Hewlett Packard Enterprise Development LP  
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -31,20 +31,22 @@
   The GetModeData() function is used to read the current mode data (operational
   parameters) for this HTTP protocol instance.
 
   @param[in]  ThisPointer to EFI_HTTP_PROTOCOL instance.
   @param[out] HttpConfigData  Point to buffer for operational parameters 
of this
-  HTTP instance.
+  HTTP instance. It is the responsibility of 
the caller 
+  to allocat

[edk2] [Patch] NetworkPkg/UefiPxeBcDxe: Fix the redundant condition check

2017-09-27 Thread Jiaxin Wu
Cc: Santhapur Naveen 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c 
b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
index 568360d..9f5be15 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
@@ -1,9 +1,9 @@
 /** @file
   Support functions implementation for UefiPxeBc Driver.
 
-  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
   http://opensource.org/licenses/bsd-license.php.
@@ -422,11 +422,11 @@ PxeBcIcmp6ErrorDpcHandle (
 
   Type = *((UINT8 *) RxData->FragmentTable[0].FragmentBuffer);
 
   if (Type != ICMP_V6_DEST_UNREACHABLE &&
   Type != ICMP_V6_PACKET_TOO_BIG &&
-  Type != ICMP_V6_PACKET_TOO_BIG &&
+  Type != ICMP_V6_TIME_EXCEEDED &&
   Type != ICMP_V6_PARAMETER_PROBLEM) {
 //
 // The type of the receveid packet should be an ICMP6 error message.
 //
 gBS->SignalEvent (RxData->RecycleSignal);
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] NetworkPkg/IScsiDxe: Display InitiatorInfo in attempt page even DHCP enabled.

2017-10-12 Thread Jiaxin Wu
Cc: Karunakar P 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr 
b/NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr
index d401419..35e8f9a 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr
+++ b/NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr
@@ -189,13 +189,14 @@ formset
 flags  = INTERACTIVE,
 key= KEY_DHCP_ENABLE,
 endcheckbox;
 endif;
 
-suppressif ideqval ISCSI_CONFIG_IFR_NVDATA.InitiatorInfoFromDhcp == 0x01 OR
-   ideqval ISCSI_CONFIG_IFR_NVDATA.IpMode == IP_MODE_IP6 OR 
+suppressif ideqval ISCSI_CONFIG_IFR_NVDATA.IpMode == IP_MODE_IP6 OR 
ideqval ISCSI_CONFIG_IFR_NVDATA.IpMode == IP_MODE_AUTOCONFIG;
+   
+grayoutif ideqval ISCSI_CONFIG_IFR_NVDATA.InitiatorInfoFromDhcp == 0x01;
 string  varid   = ISCSI_CONFIG_IFR_NVDATA.LocalIp,
 prompt  = STRING_TOKEN(STR_ISCSI_LOCAL_IP_ADDRESS),
 help= STRING_TOKEN(STR_ISCSI_IP_ADDRESS_HELP),
 flags   = INTERACTIVE,
 key = KEY_LOCAL_IP,
@@ -218,10 +219,11 @@ formset
 flags   = INTERACTIVE,
 key = KEY_GATE_WAY,
 minsize = IP4_MIN_SIZE,
 maxsize = IP4_MAX_SIZE,
 endstring;
+endif;
 
 endif;
 
 suppressif ideqval ISCSI_CONFIG_IFR_NVDATA.IpMode == IP_MODE_AUTOCONFIG;
 subtitle text = STRING_TOKEN(STR_NULL);
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch v2 0/2] NetworkPkg/IScsiDxe: Display InitiatorInfo correctly.

2017-10-15 Thread Jiaxin Wu
Cc: Karunakar P 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 

Jiaxin Wu (2):
  NetworkPkg/IScsiDxe: Fix the incorrect/needless DHCP process.
  NetworkPkg/IScsiDxe: Display InitiatorInfo in attempt page even DHCP enabled.

 NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr | 6 --
 NetworkPkg/IScsiDxe/IScsiMisc.c| 7 +--
 2 files changed, 9 insertions(+), 4 deletions(-)

-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch v2 2/2] NetworkPkg/IScsiDxe: Display InitiatorInfo in attempt page even DHCP enabled.

2017-10-15 Thread Jiaxin Wu
Cc: Karunakar P 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr 
b/NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr
index d401419..35e8f9a 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr
+++ b/NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr
@@ -189,13 +189,14 @@ formset
 flags  = INTERACTIVE,
 key= KEY_DHCP_ENABLE,
 endcheckbox;
 endif;
 
-suppressif ideqval ISCSI_CONFIG_IFR_NVDATA.InitiatorInfoFromDhcp == 0x01 OR
-   ideqval ISCSI_CONFIG_IFR_NVDATA.IpMode == IP_MODE_IP6 OR 
+suppressif ideqval ISCSI_CONFIG_IFR_NVDATA.IpMode == IP_MODE_IP6 OR 
ideqval ISCSI_CONFIG_IFR_NVDATA.IpMode == IP_MODE_AUTOCONFIG;
+   
+grayoutif ideqval ISCSI_CONFIG_IFR_NVDATA.InitiatorInfoFromDhcp == 0x01;
 string  varid   = ISCSI_CONFIG_IFR_NVDATA.LocalIp,
 prompt  = STRING_TOKEN(STR_ISCSI_LOCAL_IP_ADDRESS),
 help= STRING_TOKEN(STR_ISCSI_IP_ADDRESS_HELP),
 flags   = INTERACTIVE,
 key = KEY_LOCAL_IP,
@@ -218,10 +219,11 @@ formset
 flags   = INTERACTIVE,
 key = KEY_GATE_WAY,
 minsize = IP4_MIN_SIZE,
 maxsize = IP4_MAX_SIZE,
 endstring;
+endif;
 
 endif;
 
 suppressif ideqval ISCSI_CONFIG_IFR_NVDATA.IpMode == IP_MODE_AUTOCONFIG;
 subtitle text = STRING_TOKEN(STR_NULL);
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch v2 1/2] NetworkPkg/IScsiDxe: Fix the incorrect/needless DHCP process.

2017-10-15 Thread Jiaxin Wu
The existing attempt should not trigger the DHCP process if it
doesn't associates with the current NIC. That's incorrect when
displaying the initiator info in attempt page.

Cc: Karunakar P 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/IScsiDxe/IScsiMisc.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMisc.c
index efd05cf..0a0a3f5 100644
--- a/NetworkPkg/IScsiDxe/IScsiMisc.c
+++ b/NetworkPkg/IScsiDxe/IScsiMisc.c
@@ -1992,13 +1992,16 @@ IScsiGetConfigData (
  AttemptTmp
  );
 
   continue;
 }
-  } else if (AttemptTmp->SessionConfigData.InitiatorInfoFromDhcp && 
!AttemptTmp->ValidPath) {
+  } else if (AttemptTmp->SessionConfigData.InitiatorInfoFromDhcp && 
+ !AttemptTmp->ValidPath && 
+ AttemptTmp->NicIndex == mPrivate->CurrentNic) {
 //
-// Get DHCP information for already added, but failed, attempt.
+// If the attempt associates with the current NIC, we can 
+// get DHCP information for already added, but failed, attempt.
 //
 AttemptTmp->DhcpSuccess = FALSE;
 if (!mPrivate->Ipv6Flag && (AttemptTmp->SessionConfigData.IpMode == 
IP_MODE_IP4)) {
   Status = IScsiDoDhcp (Private->Image, Private->Controller, 
AttemptTmp);
   if (!EFI_ERROR (Status)) {
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 0/2] Add IPv6 support condition check for HTTP/ISCSI.

2017-10-16 Thread Jiaxin Wu
Base on the request of https://bugzilla.tianocore.org/show_bug.cgi?id=710,
we provide this patch to IPv6 condition check by leveraging AIP Protocol.

Cc: Karunakar P 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Karunakar P 
Signed-off-by: Wu Jiaxin 

Jiaxin Wu (2):
  NetworkPkg/HttpBootDxe: Add IPv6 support condition check.
  NetworkPkg/IScsiDxe: Add IPv6 support condition check.

 NetworkPkg/HttpBootDxe/HttpBootDxe.c   | 115 +++-
 NetworkPkg/HttpBootDxe/HttpBootDxe.h   |   2 +
 NetworkPkg/HttpBootDxe/HttpBootDxe.inf |   4 +-
 NetworkPkg/IScsiDxe/IScsiConfig.c  |  18 +
 NetworkPkg/IScsiDxe/IScsiDriver.c  |   2 +-
 NetworkPkg/IScsiDxe/IScsiDriver.h  |   1 +
 NetworkPkg/IScsiDxe/IScsiDxe.inf   |   2 +
 NetworkPkg/IScsiDxe/IScsiImpl.h|   1 +
 NetworkPkg/IScsiDxe/IScsiMisc.c| 135 -
 NetworkPkg/IScsiDxe/IScsiMisc.h|   4 +-
 10 files changed, 278 insertions(+), 6 deletions(-)

-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 2/2] NetworkPkg/IScsiDxe: Add IPv6 support condition check.

2017-10-16 Thread Jiaxin Wu
Base on the request of https://bugzilla.tianocore.org/show_bug.cgi?id=710,
we provide this patch to IPv6 condition check by leveraging AIP Protocol.

Cc: Karunakar P 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Karunakar P 
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/IScsiDxe/IScsiConfig.c |  18 +
 NetworkPkg/IScsiDxe/IScsiDriver.c |   2 +-
 NetworkPkg/IScsiDxe/IScsiDriver.h |   1 +
 NetworkPkg/IScsiDxe/IScsiDxe.inf  |   2 +
 NetworkPkg/IScsiDxe/IScsiImpl.h   |   1 +
 NetworkPkg/IScsiDxe/IScsiMisc.c   | 135 +-
 NetworkPkg/IScsiDxe/IScsiMisc.h   |   4 +-
 7 files changed, 159 insertions(+), 4 deletions(-)

diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c 
b/NetworkPkg/IScsiDxe/IScsiConfig.c
index 52e51d6..082020d 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfig.c
+++ b/NetworkPkg/IScsiDxe/IScsiConfig.c
@@ -3419,10 +3419,13 @@ IScsiFormCallback (
   EFI_IP_ADDRESS  Gateway;
   ISCSI_CONFIG_IFR_NVDATA *IfrNvData;
   ISCSI_CONFIG_IFR_NVDATA OldIfrNvData;
   EFI_STATUS  Status;
   EFI_INPUT_KEY   Key;
+  ISCSI_NIC_INFO  *NicInfo;
+
+  NicInfo = NULL;
 
   if ((Action == EFI_BROWSER_ACTION_FORM_OPEN) || (Action == 
EFI_BROWSER_ACTION_FORM_CLOSE)) {
 //
 // Do nothing for UEFI OPEN/CLOSE Action
 //
@@ -3589,10 +3592,25 @@ IScsiFormCallback (
   break;
 
 case KEY_IP_MODE:
   switch (Value->u8) {
   case IP_MODE_IP6:
+NicInfo = IScsiGetNicInfoByIndex (Private->Current->NicIndex); 
+if(!NicInfo->Ipv6Available) {  
+ //
+  // Current NIC doesn't Support IPv6, hence use IPv4.
+  //
+  IfrNvData->IpMode = IP_MODE_IP4;
+   
+  CreatePopUp (
+EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+&Key,
+L"Current NIC doesn't Support IPv6!",
+NULL
+);
+}
+ 
   case IP_MODE_IP4:
 ZeroMem (IfrNvData->TargetIp, sizeof (IfrNvData->TargetIp));
 Private->Current->AutoConfigureMode = 0;
 
 break;
diff --git a/NetworkPkg/IScsiDxe/IScsiDriver.c 
b/NetworkPkg/IScsiDxe/IScsiDriver.c
index 2249919..fbeef97 100644
--- a/NetworkPkg/IScsiDxe/IScsiDriver.c
+++ b/NetworkPkg/IScsiDxe/IScsiDriver.c
@@ -438,11 +438,11 @@ IScsiStart (
   }
   
   //
   // Record the incoming NIC info.
   //
-  Status = IScsiAddNic (ControllerHandle);
+  Status = IScsiAddNic (ControllerHandle, Image);
   if (EFI_ERROR (Status)) {
 return Status;
   }
 
   //
diff --git a/NetworkPkg/IScsiDxe/IScsiDriver.h 
b/NetworkPkg/IScsiDxe/IScsiDriver.h
index 6c6e11b..2db93c5 100644
--- a/NetworkPkg/IScsiDxe/IScsiDriver.h
+++ b/NetworkPkg/IScsiDxe/IScsiDriver.h
@@ -79,10 +79,11 @@ typedef struct {
   UINT8   NicIndex;
   UINT16  VlanId;
   UINTN   BusNumber;
   UINTN   DeviceNumber;
   UINTN   FunctionNumber;
+  BOOLEAN Ipv6Available;
 } ISCSI_NIC_INFO;
 
 typedef struct _ISCSI_PRIVATE_PROTOCOL {
   UINT32  Reserved;
 } ISCSI_PRIVATE_PROTOCOL;
diff --git a/NetworkPkg/IScsiDxe/IScsiDxe.inf b/NetworkPkg/IScsiDxe/IScsiDxe.inf
index 01998a0..319c7fe 100644
--- a/NetworkPkg/IScsiDxe/IScsiDxe.inf
+++ b/NetworkPkg/IScsiDxe/IScsiDxe.inf
@@ -115,18 +115,20 @@
   gEfiIScsiInitiatorNameProtocolGuid
   ## PRODUCES   
   gEfiAuthenticationInfoProtocolGuid
   ## SOMETIMES_CONSUMES
   gEfiAdapterInformationProtocolGuid
+  gEfiNetworkInterfaceIdentifierProtocolGuid_31 ## SOMETIMES_CONSUMES
 
 [Guids]
   gEfiEventExitBootServicesGuid ## SOMETIMES_CONSUMES ## Event
   gEfiIfrTianoGuid  ## SOMETIMES_PRODUCES ## 
UNDEFINED
   gEfiAcpiTableGuid ## SOMETIMES_CONSUMES ## 
SystemTable
   gEfiAcpi10TableGuid   ## SOMETIMES_CONSUMES ## 
SystemTable
   gEfiAcpi20TableGuid   ## SOMETIMES_CONSUMES ## 
SystemTable
   gEfiAdapterInfoNetworkBootGuid## SOMETIMES_CONSUMES ## 
UNDEFINED
+  gEfiAdapterInfoUndiIpv6SupportGuid## SOMETIMES_CONSUMES ## GUID
   
   ## SOMETIMES_PRODUCES ## Variable:L"AttemptOrder"
   ## SOMETIMES_CONSUMES ## Variable:L"AttemptOrder"
   ## SOMETIMES_PRODUCES ## Variable:L"InitialAttemptOrder"
   ## SOMETIMES_CONSUMES ## Variable:L"InitialAttemptOrder"
diff --git a/NetworkPkg/IScsiDxe/IScsiImpl.h b/NetworkPkg/IScsiDxe/IScsiImpl.h
index 741c497..9e36da0 100644
--- a/NetworkPkg/IScsiDxe/IScsiImpl.h
+++ b/NetworkPkg/IScsiDxe/IScsiImpl.h
@@ -37,10 +37,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
 #include 
 #include 
diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMisc.c
index 0a0a3f5..9e4164c 100644
--- a/NetworkPkg/IScsiDxe/IScsiMisc.c
+++ b/NetworkPkg/IScsiDxe/IScsiMisc.c
@@ -464,22 +464,

[edk2] [Patch 1/2] NetworkPkg/HttpBootDxe: Add IPv6 support condition check.

2017-10-16 Thread Jiaxin Wu
Base on the request of https://bugzilla.tianocore.org/show_bug.cgi?id=710,
we provide this patch to IPv6 condition check by leveraging AIP Protocol.

Cc: Karunakar P 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Karunakar P 
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/HttpBootDxe/HttpBootDxe.c   | 115 -
 NetworkPkg/HttpBootDxe/HttpBootDxe.h   |   2 +
 NetworkPkg/HttpBootDxe/HttpBootDxe.inf |   4 +-
 3 files changed, 119 insertions(+), 2 deletions(-)

diff --git a/NetworkPkg/HttpBootDxe/HttpBootDxe.c 
b/NetworkPkg/HttpBootDxe/HttpBootDxe.c
index 642e0fe..1a67a87 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootDxe.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootDxe.c
@@ -1,9 +1,9 @@
 /** @file
   Driver Binding functions implementation for UEFI HTTP boot.
 
-Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
 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.
  
 
@@ -33,10 +33,106 @@ EFI_DRIVER_BINDING_PROTOCOL gHttpBootIp6DxeDriverBinding = 
{
   HTTP_BOOT_DXE_VERSION,
   NULL,
   NULL
 };
 
+
+
+/**
+  Check whether UNDI protocol supports IPv6.
+
+  @param[in]   ControllerHandle  Controller handle.
+  @param[in]   Private   Pointer to HTTP_BOOT_PRIVATE_DATA.
+  @param[out]  Ipv6Support   TRUE if UNDI supports IPv6.
+
+  @retval EFI_SUCCESSGet the result whether UNDI supports IPv6 by 
NII or AIP protocol successfully.
+  @retval EFI_NOT_FOUND  Don't know whether UNDI supports IPv6 since 
NII or AIP is not available.
+
+**/
+EFI_STATUS
+HttpBootCheckIpv6Support (
+  IN  EFI_HANDLE   ControllerHandle,
+  IN  HTTP_BOOT_PRIVATE_DATA   *Private,
+  OUT BOOLEAN  *Ipv6Support
+  )
+{
+  EFI_HANDLE   Handle;
+  EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
+  EFI_STATUS   Status;
+  EFI_GUID *InfoTypesBuffer;
+  UINTNInfoTypeBufferCount;
+  UINTNTypeIndex;
+  BOOLEAN  Supported;
+  VOID *InfoBlock;
+  UINTNInfoBlockSize;
+
+  ASSERT (Private != NULL && Ipv6Support != NULL);
+
+  //
+  // Check whether the UNDI supports IPv6 by NII protocol.
+  //
+  if (Private->Nii != NULL) {
+*Ipv6Support = Private->Nii->Ipv6Supported;
+return EFI_SUCCESS;
+  }
+
+  //
+  // Get the NIC handle by SNP protocol.
+  //  
+  Handle = NetLibGetSnpHandle (ControllerHandle, NULL);
+  if (Handle == NULL) {
+return EFI_NOT_FOUND;
+  }
+
+  Aip= NULL;
+  Status = gBS->HandleProtocol (
+  Handle,
+  &gEfiAdapterInformationProtocolGuid,
+  (VOID *) &Aip
+  );
+  if (EFI_ERROR (Status) || Aip == NULL) {
+return EFI_NOT_FOUND;
+  }
+
+  InfoTypesBuffer = NULL;
+  InfoTypeBufferCount = 0;
+  Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, 
&InfoTypeBufferCount);
+  if (EFI_ERROR (Status) || InfoTypesBuffer == NULL) {
+FreePool (InfoTypesBuffer);
+return EFI_NOT_FOUND;
+  }
+
+  Supported = FALSE;
+  for (TypeIndex = 0; TypeIndex < InfoTypeBufferCount; TypeIndex++) {
+if (CompareGuid (&InfoTypesBuffer[TypeIndex], 
&gEfiAdapterInfoUndiIpv6SupportGuid)) {
+  Supported = TRUE;
+  break;
+}
+  }
+
+  FreePool (InfoTypesBuffer);
+  if (!Supported) {
+return EFI_NOT_FOUND;
+  }
+
+  //
+  // We now have adapter information block.
+  //
+  InfoBlock = NULL;
+  InfoBlockSize = 0;
+  Status = Aip->GetInformation (Aip, &gEfiAdapterInfoUndiIpv6SupportGuid, 
&InfoBlock, &InfoBlockSize);
+  if (EFI_ERROR (Status) || InfoBlock == NULL) {
+FreePool (InfoBlock);
+return EFI_NOT_FOUND;
+  }  
+
+  *Ipv6Support = ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *) 
InfoBlock)->Ipv6Support;
+  FreePool (InfoBlock);
+  
+  return EFI_SUCCESS;
+}
+
 /**
   Destroy the HTTP child based on IPv4 stack.
 
   @param[in]  This  Pointer to the EFI_DRIVER_BINDING_PROTOCOL.
   @param[in]  Private   Pointer to HTTP_BOOT_PRIVATE_DATA.
@@ -780,10 +876,11 @@ HttpBootIp6DxeDriverBindingStart (
   EFI_STATUS Status;
   HTTP_BOOT_PRIVATE_DATA *Private;
   EFI_DEV_PATH   *Node;
   EFI_DEVICE_PATH_PROTOCOL   *DevicePath;
   UINT32 *Id;
+  BOOLEANIpv6Available;
   
   Status = gBS->OpenProtocol (
   ControllerHandle,
   &gEfiCallerIdGuid,
   (VOID **) &Id,
@@ -856,10 +953,26 @@ HttpBootIp6DxeDriverBindingStart (
 if (EFI_ERROR (Status)) {
   goto ON_ERRO

[edk2] [Patch v3 0/3] NetworkPkg/IScsiDxe: Display InitiatorInfo correctly.

2017-10-17 Thread Jiaxin Wu
Cc: Karunakar P 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 

Jiaxin Wu (3):
  NetworkPkg/IScsiDxe: Fix the incorrect/needless DHCP process.
  NetworkPkg/IScsiDxe: Clean the previous ConfigData when switching the IP mode.
  NetworkPkg/IScsiDxe: Display InitiatorInfo in attempt page even DHCP enabled.

 NetworkPkg/IScsiDxe/IScsiConfig.c  | 9 -
 NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr | 6 --
 NetworkPkg/IScsiDxe/IScsiMisc.c| 7 +--
 3 files changed, 17 insertions(+), 5 deletions(-)

-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch v3 1/3] NetworkPkg/IScsiDxe: Fix the incorrect/needless DHCP process.

2017-10-17 Thread Jiaxin Wu
The existing attempt should not trigger the DHCP process if it
doesn't associates with the current NIC. That's incorrect when
displaying the initiator info in attempt page.

Cc: Karunakar P 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/IScsiDxe/IScsiMisc.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMisc.c
index efd05cf..0a0a3f5 100644
--- a/NetworkPkg/IScsiDxe/IScsiMisc.c
+++ b/NetworkPkg/IScsiDxe/IScsiMisc.c
@@ -1992,13 +1992,16 @@ IScsiGetConfigData (
  AttemptTmp
  );
 
   continue;
 }
-  } else if (AttemptTmp->SessionConfigData.InitiatorInfoFromDhcp && 
!AttemptTmp->ValidPath) {
+  } else if (AttemptTmp->SessionConfigData.InitiatorInfoFromDhcp && 
+ !AttemptTmp->ValidPath && 
+ AttemptTmp->NicIndex == mPrivate->CurrentNic) {
 //
-// Get DHCP information for already added, but failed, attempt.
+// If the attempt associates with the current NIC, we can 
+// get DHCP information for already added, but failed, attempt.
 //
 AttemptTmp->DhcpSuccess = FALSE;
 if (!mPrivate->Ipv6Flag && (AttemptTmp->SessionConfigData.IpMode == 
IP_MODE_IP4)) {
   Status = IScsiDoDhcp (Private->Image, Private->Controller, 
AttemptTmp);
   if (!EFI_ERROR (Status)) {
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch v3 3/3] NetworkPkg/IScsiDxe: Display InitiatorInfo in attempt page even DHCP enabled.

2017-10-17 Thread Jiaxin Wu
Cc: Karunakar P 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr 
b/NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr
index d401419..35e8f9a 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr
+++ b/NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr
@@ -189,13 +189,14 @@ formset
 flags  = INTERACTIVE,
 key= KEY_DHCP_ENABLE,
 endcheckbox;
 endif;
 
-suppressif ideqval ISCSI_CONFIG_IFR_NVDATA.InitiatorInfoFromDhcp == 0x01 OR
-   ideqval ISCSI_CONFIG_IFR_NVDATA.IpMode == IP_MODE_IP6 OR 
+suppressif ideqval ISCSI_CONFIG_IFR_NVDATA.IpMode == IP_MODE_IP6 OR 
ideqval ISCSI_CONFIG_IFR_NVDATA.IpMode == IP_MODE_AUTOCONFIG;
+   
+grayoutif ideqval ISCSI_CONFIG_IFR_NVDATA.InitiatorInfoFromDhcp == 0x01;
 string  varid   = ISCSI_CONFIG_IFR_NVDATA.LocalIp,
 prompt  = STRING_TOKEN(STR_ISCSI_LOCAL_IP_ADDRESS),
 help= STRING_TOKEN(STR_ISCSI_IP_ADDRESS_HELP),
 flags   = INTERACTIVE,
 key = KEY_LOCAL_IP,
@@ -218,10 +219,11 @@ formset
 flags   = INTERACTIVE,
 key = KEY_GATE_WAY,
 minsize = IP4_MIN_SIZE,
 maxsize = IP4_MAX_SIZE,
 endstring;
+endif;
 
 endif;
 
 suppressif ideqval ISCSI_CONFIG_IFR_NVDATA.IpMode == IP_MODE_AUTOCONFIG;
 subtitle text = STRING_TOKEN(STR_NULL);
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch v3 2/3] NetworkPkg/IScsiDxe: Clean the previous ConfigData when switching the IP mode.

2017-10-17 Thread Jiaxin Wu
Cc: Karunakar P 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/IScsiDxe/IScsiConfig.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c 
b/NetworkPkg/IScsiDxe/IScsiConfig.c
index 52e51d6..f20f590 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfig.c
+++ b/NetworkPkg/IScsiDxe/IScsiConfig.c
@@ -3590,13 +3590,20 @@ IScsiFormCallback (
 
 case KEY_IP_MODE:
   switch (Value->u8) {
   case IP_MODE_IP6:
   case IP_MODE_IP4:
+ZeroMem (IfrNvData->LocalIp, sizeof (IfrNvData->LocalIp));
+ZeroMem (IfrNvData->SubnetMask, sizeof (IfrNvData->SubnetMask));
+ZeroMem (IfrNvData->Gateway, sizeof (IfrNvData->Gateway));
 ZeroMem (IfrNvData->TargetIp, sizeof (IfrNvData->TargetIp));
 Private->Current->AutoConfigureMode = 0;
-
+ZeroMem (&Private->Current->SessionConfigData.LocalIp, sizeof 
(EFI_IP_ADDRESS));
+ZeroMem (&Private->Current->SessionConfigData.SubnetMask, sizeof 
(EFI_IPv4_ADDRESS));
+ZeroMem (&Private->Current->SessionConfigData.Gateway, sizeof 
(EFI_IP_ADDRESS));
+ZeroMem (&Private->Current->SessionConfigData.TargetIp, sizeof 
(EFI_IP_ADDRESS));
+
 break;
   }
 
   break;
 
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch v2 1/2] NetworkPkg/HttpBootDxe: Add IPv6 support condition check.

2017-10-17 Thread Jiaxin Wu
v2:
* Fix the ASSERT issue.

Base on the request of https://bugzilla.tianocore.org/show_bug.cgi?id=710,
we provide this patch to IPv6 condition check by leveraging AIP Protocol.

Cc: Karunakar P 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Karunakar P 
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/HttpBootDxe/HttpBootDxe.c   | 161 +++--
 NetworkPkg/HttpBootDxe/HttpBootDxe.h   |   2 +
 NetworkPkg/HttpBootDxe/HttpBootDxe.inf |   4 +-
 3 files changed, 157 insertions(+), 10 deletions(-)

diff --git a/NetworkPkg/HttpBootDxe/HttpBootDxe.c 
b/NetworkPkg/HttpBootDxe/HttpBootDxe.c
index 642e0fe..b1f9042 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootDxe.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootDxe.c
@@ -1,9 +1,9 @@
 /** @file
   Driver Binding functions implementation for UEFI HTTP boot.
 
-Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
 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.
  
 
@@ -33,10 +33,104 @@ EFI_DRIVER_BINDING_PROTOCOL gHttpBootIp6DxeDriverBinding = 
{
   HTTP_BOOT_DXE_VERSION,
   NULL,
   NULL
 };
 
+
+
+/**
+  Check whether UNDI protocol supports IPv6.
+
+  @param[in]   Private   Pointer to HTTP_BOOT_PRIVATE_DATA.
+  @param[out]  Ipv6Support   TRUE if UNDI supports IPv6.
+
+  @retval EFI_SUCCESSGet the result whether UNDI supports IPv6 by 
NII or AIP protocol successfully.
+  @retval EFI_NOT_FOUND  Don't know whether UNDI supports IPv6 since 
NII or AIP is not available.
+
+**/
+EFI_STATUS
+HttpBootCheckIpv6Support (
+  IN  HTTP_BOOT_PRIVATE_DATA   *Private,
+  OUT BOOLEAN  *Ipv6Support
+  )
+{
+  EFI_HANDLE   Handle;
+  EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
+  EFI_STATUS   Status;
+  EFI_GUID *InfoTypesBuffer;
+  UINTNInfoTypeBufferCount;
+  UINTNTypeIndex;
+  BOOLEAN  Supported;
+  VOID *InfoBlock;
+  UINTNInfoBlockSize;
+
+  ASSERT (Private != NULL && Ipv6Support != NULL);
+
+  //
+  // Check whether the UNDI supports IPv6 by NII protocol.
+  //
+  if (Private->Nii != NULL) {
+*Ipv6Support = Private->Nii->Ipv6Supported;
+return EFI_SUCCESS;
+  }
+
+  //
+  // Get the NIC handle by SNP protocol.
+  //  
+  Handle = NetLibGetSnpHandle (Private->Controller, NULL);
+  if (Handle == NULL) {
+return EFI_NOT_FOUND;
+  }
+
+  Aip= NULL;
+  Status = gBS->HandleProtocol (
+  Handle,
+  &gEfiAdapterInformationProtocolGuid,
+  (VOID *) &Aip
+  );
+  if (EFI_ERROR (Status) || Aip == NULL) {
+return EFI_NOT_FOUND;
+  }
+
+  InfoTypesBuffer = NULL;
+  InfoTypeBufferCount = 0;
+  Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, 
&InfoTypeBufferCount);
+  if (EFI_ERROR (Status) || InfoTypesBuffer == NULL) {
+FreePool (InfoTypesBuffer);
+return EFI_NOT_FOUND;
+  }
+
+  Supported = FALSE;
+  for (TypeIndex = 0; TypeIndex < InfoTypeBufferCount; TypeIndex++) {
+if (CompareGuid (&InfoTypesBuffer[TypeIndex], 
&gEfiAdapterInfoUndiIpv6SupportGuid)) {
+  Supported = TRUE;
+  break;
+}
+  }
+
+  FreePool (InfoTypesBuffer);
+  if (!Supported) {
+return EFI_NOT_FOUND;
+  }
+
+  //
+  // We now have adapter information block.
+  //
+  InfoBlock = NULL;
+  InfoBlockSize = 0;
+  Status = Aip->GetInformation (Aip, &gEfiAdapterInfoUndiIpv6SupportGuid, 
&InfoBlock, &InfoBlockSize);
+  if (EFI_ERROR (Status) || InfoBlock == NULL) {
+FreePool (InfoBlock);
+return EFI_NOT_FOUND;
+  }  
+
+  *Ipv6Support = ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *) 
InfoBlock)->Ipv6Support;
+  FreePool (InfoBlock);
+  
+  return EFI_SUCCESS;
+}
+
 /**
   Destroy the HTTP child based on IPv4 stack.
 
   @param[in]  This  Pointer to the EFI_DRIVER_BINDING_PROTOCOL.
   @param[in]  Private   Pointer to HTTP_BOOT_PRIVATE_DATA.
@@ -65,11 +159,11 @@ HttpBootDestroyIp4Children (
   &gEfiDhcp4ServiceBindingProtocolGuid,
   Private->Dhcp4Child
   );
   }
 
-  if (Private->HttpCreated) {
+  if (Private->Ip6Nic == NULL && Private->HttpCreated) {
 HttpIoDestroyIo (&Private->HttpIo);
 Private->HttpCreated = FALSE;
   }
 
   if (Private->Ip4Nic != NULL) {
@@ -141,11 +235,11 @@ HttpBootDestroyIp6Children (
   &gEfiDhcp6ServiceBindingProtocolGuid,
   Private->Dhcp6Child
   );
   }
 
-  if (Private->HttpCreated) {
+  if (Private->Ip4Nic == NULL && Private->HttpCreated) {
 HttpIoDestroyIo(&Private->HttpIo);
 Pr

[edk2] [Patch v2 0/2] Add IPv6 support condition check.

2017-10-17 Thread Jiaxin Wu
Base on the request of https://bugzilla.tianocore.org/show_bug.cgi?id=710,
we provide this patch to IPv6 condition check by leveraging AIP Protocol.

Cc: Karunakar P 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Karunakar P 
Signed-off-by: Wu Jiaxin 

Jiaxin Wu (2):
  NetworkPkg/HttpBootDxe: Add IPv6 support condition check.
  NetworkPkg/IScsiDxe: Add IPv6 support condition check.

 NetworkPkg/HttpBootDxe/HttpBootDxe.c   | 161 +++--
 NetworkPkg/HttpBootDxe/HttpBootDxe.h   |   2 +
 NetworkPkg/HttpBootDxe/HttpBootDxe.inf |   4 +-
 NetworkPkg/IScsiDxe/IScsiConfig.c  |  18 
 NetworkPkg/IScsiDxe/IScsiDriver.c  |   2 +-
 NetworkPkg/IScsiDxe/IScsiDriver.h  |   1 +
 NetworkPkg/IScsiDxe/IScsiDxe.inf   |   2 +
 NetworkPkg/IScsiDxe/IScsiImpl.h|   1 +
 NetworkPkg/IScsiDxe/IScsiMisc.c| 135 ++-
 NetworkPkg/IScsiDxe/IScsiMisc.h|   4 +-
 10 files changed, 316 insertions(+), 14 deletions(-)

-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch v2 2/2] NetworkPkg/IScsiDxe: Add IPv6 support condition check.

2017-10-17 Thread Jiaxin Wu
Base on the request of https://bugzilla.tianocore.org/show_bug.cgi?id=710,
we provide this patch to IPv6 condition check by leveraging AIP Protocol.

Cc: Karunakar P 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Karunakar P 
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/IScsiDxe/IScsiConfig.c |  18 +
 NetworkPkg/IScsiDxe/IScsiDriver.c |   2 +-
 NetworkPkg/IScsiDxe/IScsiDriver.h |   1 +
 NetworkPkg/IScsiDxe/IScsiDxe.inf  |   2 +
 NetworkPkg/IScsiDxe/IScsiImpl.h   |   1 +
 NetworkPkg/IScsiDxe/IScsiMisc.c   | 135 +-
 NetworkPkg/IScsiDxe/IScsiMisc.h   |   4 +-
 7 files changed, 159 insertions(+), 4 deletions(-)

diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c 
b/NetworkPkg/IScsiDxe/IScsiConfig.c
index f20f590..3ce37c5 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfig.c
+++ b/NetworkPkg/IScsiDxe/IScsiConfig.c
@@ -3419,10 +3419,13 @@ IScsiFormCallback (
   EFI_IP_ADDRESS  Gateway;
   ISCSI_CONFIG_IFR_NVDATA *IfrNvData;
   ISCSI_CONFIG_IFR_NVDATA OldIfrNvData;
   EFI_STATUS  Status;
   EFI_INPUT_KEY   Key;
+  ISCSI_NIC_INFO  *NicInfo;
+
+  NicInfo = NULL;
 
   if ((Action == EFI_BROWSER_ACTION_FORM_OPEN) || (Action == 
EFI_BROWSER_ACTION_FORM_CLOSE)) {
 //
 // Do nothing for UEFI OPEN/CLOSE Action
 //
@@ -3589,10 +3592,25 @@ IScsiFormCallback (
   break;
 
 case KEY_IP_MODE:
   switch (Value->u8) {
   case IP_MODE_IP6:
+NicInfo = IScsiGetNicInfoByIndex (Private->Current->NicIndex); 
+if(!NicInfo->Ipv6Available) {  
+ //
+  // Current NIC doesn't Support IPv6, hence use IPv4.
+  //
+  IfrNvData->IpMode = IP_MODE_IP4;
+   
+  CreatePopUp (
+EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+&Key,
+L"Current NIC doesn't Support IPv6!",
+NULL
+);
+}
+ 
   case IP_MODE_IP4:
 ZeroMem (IfrNvData->LocalIp, sizeof (IfrNvData->LocalIp));
 ZeroMem (IfrNvData->SubnetMask, sizeof (IfrNvData->SubnetMask));
 ZeroMem (IfrNvData->Gateway, sizeof (IfrNvData->Gateway));
 ZeroMem (IfrNvData->TargetIp, sizeof (IfrNvData->TargetIp));
diff --git a/NetworkPkg/IScsiDxe/IScsiDriver.c 
b/NetworkPkg/IScsiDxe/IScsiDriver.c
index 2249919..fbeef97 100644
--- a/NetworkPkg/IScsiDxe/IScsiDriver.c
+++ b/NetworkPkg/IScsiDxe/IScsiDriver.c
@@ -438,11 +438,11 @@ IScsiStart (
   }
   
   //
   // Record the incoming NIC info.
   //
-  Status = IScsiAddNic (ControllerHandle);
+  Status = IScsiAddNic (ControllerHandle, Image);
   if (EFI_ERROR (Status)) {
 return Status;
   }
 
   //
diff --git a/NetworkPkg/IScsiDxe/IScsiDriver.h 
b/NetworkPkg/IScsiDxe/IScsiDriver.h
index 6c6e11b..2db93c5 100644
--- a/NetworkPkg/IScsiDxe/IScsiDriver.h
+++ b/NetworkPkg/IScsiDxe/IScsiDriver.h
@@ -79,10 +79,11 @@ typedef struct {
   UINT8   NicIndex;
   UINT16  VlanId;
   UINTN   BusNumber;
   UINTN   DeviceNumber;
   UINTN   FunctionNumber;
+  BOOLEAN Ipv6Available;
 } ISCSI_NIC_INFO;
 
 typedef struct _ISCSI_PRIVATE_PROTOCOL {
   UINT32  Reserved;
 } ISCSI_PRIVATE_PROTOCOL;
diff --git a/NetworkPkg/IScsiDxe/IScsiDxe.inf b/NetworkPkg/IScsiDxe/IScsiDxe.inf
index 01998a0..319c7fe 100644
--- a/NetworkPkg/IScsiDxe/IScsiDxe.inf
+++ b/NetworkPkg/IScsiDxe/IScsiDxe.inf
@@ -115,18 +115,20 @@
   gEfiIScsiInitiatorNameProtocolGuid
   ## PRODUCES   
   gEfiAuthenticationInfoProtocolGuid
   ## SOMETIMES_CONSUMES
   gEfiAdapterInformationProtocolGuid
+  gEfiNetworkInterfaceIdentifierProtocolGuid_31 ## SOMETIMES_CONSUMES
 
 [Guids]
   gEfiEventExitBootServicesGuid ## SOMETIMES_CONSUMES ## Event
   gEfiIfrTianoGuid  ## SOMETIMES_PRODUCES ## 
UNDEFINED
   gEfiAcpiTableGuid ## SOMETIMES_CONSUMES ## 
SystemTable
   gEfiAcpi10TableGuid   ## SOMETIMES_CONSUMES ## 
SystemTable
   gEfiAcpi20TableGuid   ## SOMETIMES_CONSUMES ## 
SystemTable
   gEfiAdapterInfoNetworkBootGuid## SOMETIMES_CONSUMES ## 
UNDEFINED
+  gEfiAdapterInfoUndiIpv6SupportGuid## SOMETIMES_CONSUMES ## GUID
   
   ## SOMETIMES_PRODUCES ## Variable:L"AttemptOrder"
   ## SOMETIMES_CONSUMES ## Variable:L"AttemptOrder"
   ## SOMETIMES_PRODUCES ## Variable:L"InitialAttemptOrder"
   ## SOMETIMES_CONSUMES ## Variable:L"InitialAttemptOrder"
diff --git a/NetworkPkg/IScsiDxe/IScsiImpl.h b/NetworkPkg/IScsiDxe/IScsiImpl.h
index 741c497..9e36da0 100644
--- a/NetworkPkg/IScsiDxe/IScsiImpl.h
+++ b/NetworkPkg/IScsiDxe/IScsiImpl.h
@@ -37,10 +37,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
 #include 
 #include 
diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/I

[edk2] [Patch] NetworkPkg/TlsAuthConfigDxe: Remove the extra FreePool

2017-10-18 Thread Jiaxin Wu
Cc: Long Qin 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.c 
b/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.c
index 351656f..403afbb 100644
--- a/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.c
+++ b/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.c
@@ -1,9 +1,9 @@
 /** @file
   The DriverEntryPoint for TlsAuthConfigDxe driver.
 
-  Copyright (c) 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
   http://opensource.org/licenses/bsd-license.php.
@@ -126,10 +126,9 @@ TlsAuthConfigDxeDriverEntryPoint (
 
   return EFI_SUCCESS;
 
 ON_ERROR:
   TlsAuthConfigFormUnload (PrivateData);
-  FreePool (PrivateData);
-
+  
   return Status;
 }
 
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] MdeModulePkg/Ip4Dxe: Trigger Ip4Config2 to retrieve the default address.

2017-10-19 Thread Jiaxin Wu
According the UEFI spec 2.7 A:
In section 28.3.2 for the IpConfigData.UseDefaultAddress, "While set to
TRUE, Configure() will trigger the EFI_IP4_CONFIG2_PROTOCOL to retrieve
the default IPv4 address if it is not available yet."
In section 28.5 for the Ip4Config2PolicyDhcp, "...All of these configurations
are retrieved from DHCP server or other auto-configuration mechanism."

This patch is to align with the above description. When the default IPv4
address is not available and IpConfigData.UseDefaultAddress is set to TRUE,
Ip4Config2 protocol will be called to retrieve the default address by setting
the policy to Ip4Config2PolicyDhcp.

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c | 25 +
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c 
b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
index 3cdf8ec..fc5812e 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
@@ -594,13 +594,17 @@ Ip4ConfigProtocol (
   IP4_INTERFACE *IpIf;
   EFI_STATUSStatus;
   IP4_ADDR  Ip;
   IP4_ADDR  Netmask;
   EFI_ARP_PROTOCOL  *Arp;
+  EFI_IP4_CONFIG2_PROTOCOL  *Ip4Config2;
+  EFI_IP4_CONFIG2_POLICYPolicy;
 
   IpSb = IpInstance->Service;
 
+  Ip4Config2  = NULL;
+
   //
   // User is changing packet filters. It must be stopped
   // before the station address can be changed.
   //
   if (IpInstance->State == IP4_STATE_CONFIGED) {
@@ -675,14 +679,27 @@ Ip4ConfigProtocol (
   } else {
 //
 // Use the default address. Check the state.
 //
 if (IpSb->State == IP4_SERVICE_UNSTARTED) {
-  Status = Ip4StartAutoConfig (&IpSb->Ip4Config2Instance);
-
-  if (EFI_ERROR (Status)) {
-goto ON_ERROR;
+  //
+  // Trigger the EFI_IP4_CONFIG2_PROTOCOL to retrieve the 
+  // default IPv4 address if it is not available yet.
+  //
+  Policy = IpSb->Ip4Config2Instance.Policy;
+  if (Policy != Ip4Config2PolicyDhcp) {
+Ip4Config2 = &IpSb->Ip4Config2Instance.Ip4Config2;
+Policy = Ip4Config2PolicyDhcp;
+Status= Ip4Config2->SetData (
+  Ip4Config2,
+  Ip4Config2DataTypePolicy,
+  sizeof (EFI_IP4_CONFIG2_POLICY),
+  &Policy
+  );
+if (EFI_ERROR (Status)) {
+  goto ON_ERROR;
+}
   }
 }
 
 IpIf = IpSb->DefaultInterface;
 NET_GET_REF (IpSb->DefaultInterface);
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] NetworkPkg/IScsiDxe: Clear the old IFR TargetIp to avoid sharing it with other attempts.

2017-10-26 Thread Jiaxin Wu
Cc: Karunakar P 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/IScsiDxe/IScsiConfig.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c 
b/NetworkPkg/IScsiDxe/IScsiConfig.c
index 3ce37c5..3382982 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfig.c
+++ b/NetworkPkg/IScsiDxe/IScsiConfig.c
@@ -539,10 +539,11 @@ IScsiConvertAttemptConfigDataToIfrNvData (
 IScsiIpToStr (&Ip, FALSE, IfrNvData->LocalIp);
 CopyMem (&Ip.v4, &SessionConfigData->SubnetMask, sizeof 
(EFI_IPv4_ADDRESS));
 IScsiIpToStr (&Ip, FALSE, IfrNvData->SubnetMask);
 CopyMem (&Ip.v4, &SessionConfigData->Gateway, sizeof (EFI_IPv4_ADDRESS));
 IScsiIpToStr (&Ip, FALSE, IfrNvData->Gateway);
+ZeroMem (IfrNvData->TargetIp, sizeof (IfrNvData->TargetIp));
 if (SessionConfigData->TargetIp.v4.Addr[0] != '\0') {
   CopyMem (&Ip.v4, &SessionConfigData->TargetIp, sizeof 
(EFI_IPv4_ADDRESS));
   IScsiIpToStr (&Ip, FALSE, IfrNvData->TargetIp);
 }
 
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 1/2] NetworkPkg/HttpBootDxe: Add check to avoid use NULL pointer

2017-10-26 Thread Jiaxin Wu
Cc: Wu Hao A 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/HttpBootDxe/HttpBootDxe.c | 50 +++-
 1 file changed, 27 insertions(+), 23 deletions(-)

diff --git a/NetworkPkg/HttpBootDxe/HttpBootDxe.c 
b/NetworkPkg/HttpBootDxe/HttpBootDxe.c
index b1f9042..8a61f51 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootDxe.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootDxe.c
@@ -613,23 +613,25 @@ HttpBootIp4DxeDriverBindingStart (
   }
   
   return EFI_SUCCESS;
 
 ON_ERROR:
-  if (FirstStart) {
-gBS->UninstallProtocolInterface (
-   ControllerHandle,
-   &gEfiCallerIdGuid,
-   &Private->Id
-   );
-  }
-  
-  HttpBootDestroyIp4Children (This, Private);
-  HttpBootConfigFormUnload (Private);
+  if (Private != NULL) {
+if (FirstStart) {
+  gBS->UninstallProtocolInterface (
+ ControllerHandle,
+ &gEfiCallerIdGuid,
+ &Private->Id
+ );
+}
+
+HttpBootDestroyIp4Children (This, Private);
+HttpBootConfigFormUnload (Private);
 
-  if (FirstStart && Private != NULL) {
-FreePool (Private);
+if (FirstStart) {
+  FreePool (Private);
+}
   }
 
   return Status;
 }
 
@@ -1142,23 +1144,25 @@ HttpBootIp6DxeDriverBindingStart (
   }
 
   return EFI_SUCCESS;

 ON_ERROR:
-  if (FirstStart) {
-gBS->UninstallProtocolInterface (
-   ControllerHandle,
-   &gEfiCallerIdGuid,
-   &Private->Id
-   );
-  }
+  if (Private != NULL) {
+if (FirstStart) {
+  gBS->UninstallProtocolInterface (
+ ControllerHandle,
+ &gEfiCallerIdGuid,
+ &Private->Id
+ );
+}
 
-  HttpBootDestroyIp6Children(This, Private);
-  HttpBootConfigFormUnload (Private);
+HttpBootDestroyIp6Children(This, Private);
+HttpBootConfigFormUnload (Private);
 
-  if (FirstStart && Private != NULL) {
-FreePool (Private);
+if (FirstStart) {
+  FreePool (Private);
+}
   }
 
   return Status;
 }
 
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 0/2] Add check to avoid use NULL pointer

2017-10-26 Thread Jiaxin Wu
Cc: Wu Hao A 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 

Jiaxin Wu (2):
  NetworkPkg/HttpBootDxe: Add check to avoid use NULL pointer
  NetworkPkg/IScsiDxe: Add check to avoid use NULL pointer

 NetworkPkg/HttpBootDxe/HttpBootDxe.c | 50 +++-
 NetworkPkg/IScsiDxe/IScsiConfig.c|  4 +++
 2 files changed, 31 insertions(+), 23 deletions(-)

-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 2/2] NetworkPkg/IScsiDxe: Add check to avoid use NULL pointer

2017-10-26 Thread Jiaxin Wu
Cc: Wu Hao A 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/IScsiDxe/IScsiConfig.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c 
b/NetworkPkg/IScsiDxe/IScsiConfig.c
index 3382982..62df367 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfig.c
+++ b/NetworkPkg/IScsiDxe/IScsiConfig.c
@@ -3594,10 +3594,14 @@ IScsiFormCallback (
 
 case KEY_IP_MODE:
   switch (Value->u8) {
   case IP_MODE_IP6:
 NicInfo = IScsiGetNicInfoByIndex (Private->Current->NicIndex); 
+if(NicInfo == NULL) {
+  break;
+}
+
 if(!NicInfo->Ipv6Available) {  
  //
   // Current NIC doesn't Support IPv6, hence use IPv4.
   //
   IfrNvData->IpMode = IP_MODE_IP4;
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] NetworkPkg/IScsiDxe: Correct the DnsMode value according the target info.

2017-12-24 Thread Jiaxin Wu
This patch is to resolve the issue recorded @
https://bugzilla.tianocore.org/show_bug.cgi?id=823.

Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Karunakar P 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
Tested-by: Karunakar P 
---
 NetworkPkg/IScsiDxe/IScsiDhcp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/NetworkPkg/IScsiDxe/IScsiDhcp.c b/NetworkPkg/IScsiDxe/IScsiDhcp.c
index e6f6972..e343523 100644
--- a/NetworkPkg/IScsiDxe/IScsiDhcp.c
+++ b/NetworkPkg/IScsiDxe/IScsiDhcp.c
@@ -132,10 +132,11 @@ IScsiDhcpExtractRootPath (
   return EFI_INVALID_PARAMETER;
 }
 CopyMem (&ConfigNvData->TargetUrl, Field->Str, Field->Len);
 ConfigNvData->TargetUrl[Field->Len + 1] = '\0';
   } else {
+ConfigNvData->DnsMode = FALSE;
 ZeroMem(ConfigNvData->TargetUrl, sizeof (ConfigNvData->TargetUrl));
 Status = IScsiAsciiStrToIp (Field->Str, IpMode, &Ip);
 CopyMem (&ConfigNvData->TargetIp, &Ip, sizeof (EFI_IP_ADDRESS));
 
 if (EFI_ERROR (Status)) {
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 2/5] MdeModulePkg/DxeHttpLib: Avoid the potential memory leak when error happen.

2017-12-25 Thread Jiaxin Wu
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wang Fan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c 
b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
index 4d353d7..27b94e3 100644
--- a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
+++ b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
@@ -369,10 +369,12 @@ HttpParseUrl (
   UINT32Field;
   UINT32OldField;
   BOOLEAN   FoundAt;
   EFI_STATUSStatus;
   HTTP_URL_PARSER   *Parser;
+
+  Parser = NULL;
   
   if (Url == NULL || Length == 0 || UrlParser == NULL) {
 return EFI_INVALID_PARAMETER;
   }
 
@@ -399,10 +401,11 @@ HttpParseUrl (
 //
 State = NetHttpParseUrlChar (*Char, State);
 
 switch (State) {
 case UrlParserStateMax:
+  FreePool (Parser);
   return EFI_INVALID_PARAMETER;
   
 case UrlParserSchemeColon:
 case UrlParserSchemeColonSlash:
 case UrlParserSchemeColonSlashSlash:
@@ -461,10 +464,11 @@ HttpParseUrl (
   // If has authority component, continue to parse the username, host and port.
   //
   if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_AUTHORITY)) != 0) {
 Status = NetHttpParseAuthority (Url, FoundAt, Parser);
 if (EFI_ERROR (Status)) {
+  FreePool (Parser);
   return Status;
 }
   }
 
   *UrlParser = Parser;
@@ -1525,10 +1529,11 @@ HttpSetFieldNameAndValue (
   HttpHeader->FieldName[FieldNameSize - 1] = 0;
 
   FieldValueSize = AsciiStrSize (FieldValue);
   HttpHeader->FieldValue = AllocateZeroPool (FieldValueSize);
   if (HttpHeader->FieldValue == NULL) {
+FreePool (HttpHeader->FieldName);
 return EFI_OUT_OF_RESOURCES;
   }
   CopyMem (HttpHeader->FieldValue, FieldValue, FieldValueSize);
   HttpHeader->FieldValue[FieldValueSize - 1] = 0;
 
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 3/5] MdeModulePkg/DxeHttpLib: Check the input parameters for some APIs.

2017-12-25 Thread Jiaxin Wu
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wang Fan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdeModulePkg/Include/Library/HttpLib.h   |  1 +
 MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c | 25 -
 2 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/MdeModulePkg/Include/Library/HttpLib.h 
b/MdeModulePkg/Include/Library/HttpLib.h
index 8539820..88b56ae 100644
--- a/MdeModulePkg/Include/Library/HttpLib.h
+++ b/MdeModulePkg/Include/Library/HttpLib.h
@@ -370,10 +370,11 @@ HttpFindHeader (
   @param[in]  FieldName   FieldName of this HttpHeader, a NULL 
terminated ASCII string.
   @param[in]  FieldValue  FieldValue of this HttpHeader, a NULL 
terminated ASCII string.
 
 
   @retval EFI_SUCCESS The FieldName and FieldValue are set into 
HttpHeader successfully.
+  @retval EFI_INVALID_PARAMETER   The parameter is invalid.
   @retval EFI_OUT_OF_RESOURCESFailed to allocate resources.
 
 **/
 EFI_STATUS
 EFIAPI
diff --git a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c 
b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
index 27b94e3..38ded5d 100644
--- a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
+++ b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
@@ -1396,10 +1396,14 @@ HttpIsMessageComplete (
   IN VOID  *MsgParser
   )
 {
   HTTP_BODY_PARSER  *Parser;
 
+  if (MsgParser == NULL) {
+return FALSE;
+  }
+
   Parser = (HTTP_BODY_PARSER*) MsgParser;
 
   if (Parser->State == BodyParserComplete) {
 return TRUE;
   }
@@ -1497,10 +1501,11 @@ AsciiStrGetNextToken (
   @param[in]  FieldName   FieldName of this HttpHeader, a NULL 
terminated ASCII string.
   @param[in]  FieldValue  FieldValue of this HttpHeader, a NULL 
terminated ASCII string.
 
 
   @retval EFI_SUCCESS The FieldName and FieldValue are set into 
HttpHeader successfully.
+  @retval EFI_INVALID_PARAMETER   The parameter is invalid.
   @retval EFI_OUT_OF_RESOURCESFailed to allocate resources.
 
 **/
 EFI_STATUS
 EFIAPI
@@ -1511,10 +1516,14 @@ HttpSetFieldNameAndValue (
   )
 {
   UINTN   FieldNameSize;
   UINTN   FieldValueSize;
 
+  if (HttpHeader == NULL || FieldName == NULL || FieldValue == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+
   if (HttpHeader->FieldName != NULL) {
 FreePool (HttpHeader->FieldName);
   }
   if (HttpHeader->FieldValue != NULL) {
 FreePool (HttpHeader->FieldValue);
@@ -1728,14 +1737,10 @@ HttpGenRequestMessage (
   VOID *HttpHdr;
   EFI_HTTP_HEADER  **AppendList;
   UINTNIndex;
   EFI_HTTP_UTILITIES_PROTOCOL  *HttpUtilitiesProtocol;
 
-
-  ASSERT (Message != NULL);
-
-  *RequestMsg   = NULL;
   Status= EFI_SUCCESS;
   HttpHdrSize   = 0;
   MsgSize   = 0;
   Success   = FALSE;
   HttpHdr   = NULL;
@@ -1746,11 +1751,12 @@ HttpGenRequestMessage (
   // 1. If we have a Request, we cannot have a NULL Url
   // 2. If we have a Request, HeaderCount can not be non-zero
   // 3. If we do not have a Request, HeaderCount should be zero
   // 4. If we do not have Request and Headers, we need at least a message-body
   //
-  if ((Message->Data.Request != NULL && Url == NULL) ||
+  if ((Message == NULL || RequestMsg == NULL || RequestMsgSize == NULL) || 
+  (Message->Data.Request != NULL && Url == NULL) ||
   (Message->Data.Request != NULL && Message->HeaderCount == 0) ||
   (Message->Data.Request == NULL && Message->HeaderCount != 0) ||
   (Message->Data.Request == NULL && Message->HeaderCount == 0 && 
Message->BodyLength == 0)) {
 return EFI_INVALID_PARAMETER;
   }
@@ -1827,10 +1833,11 @@ HttpGenRequestMessage (
   MsgSize += Message->BodyLength;
 
   //
   // memory for the string that needs to be sent to TCP
   //
+  *RequestMsg   = NULL;
   *RequestMsg = AllocateZeroPool (MsgSize);
   if (*RequestMsg == NULL) {
 Status = EFI_OUT_OF_RESOURCES;
 goto Exit;
   }
@@ -2052,11 +2059,19 @@ HttpIsValidHttpHeader (
   IN  CHAR8*FieldName
   )
 {
   UINTN   Index;
 
+  if (FieldName == NULL) {
+return FALSE;
+  }
+
   for (Index = 0; Index < DeleteCount; Index++) {
+if (DeleteList[Index] == NULL) {
+  continue;
+}
+
 if (AsciiStrCmp (FieldName, DeleteList[Index]) == 0) {
   return FALSE;
 }
   }
 
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 4/5] MdeModulePkg/DxeHttpLib: Correct some return Status.

2017-12-25 Thread Jiaxin Wu
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wang Fan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdeModulePkg/Include/Library/HttpLib.h   |  5 +++--
 MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c | 11 ++-
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/MdeModulePkg/Include/Library/HttpLib.h 
b/MdeModulePkg/Include/Library/HttpLib.h
index 88b56ae..285a831 100644
--- a/MdeModulePkg/Include/Library/HttpLib.h
+++ b/MdeModulePkg/Include/Library/HttpLib.h
@@ -284,12 +284,13 @@ HttpInitMsgParser (
   @param[in] BodyLength   Length in bytes of the Body.
   @param[in] Body Pointer to the buffer of the 
message-body to be parsed.
 
   @retval EFI_SUCCESSSuccessfully parse the message-body.
   @retval EFI_INVALID_PARAMETER  MsgParser is NULL or Body is NULL or 
BodyLength is 0.
-  @retval Others Operation aborted.
-
+  @retval EFI_ABORTEDOperation aborted.
+  @retval Other  Error happened while parsing message body.
+  
 **/
 EFI_STATUS
 EFIAPI
 HttpParseMessageBody (
   IN OUT VOID  *MsgParser,
diff --git a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c 
b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
index 38ded5d..327ca9e 100644
--- a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
+++ b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
@@ -152,11 +152,11 @@ NetHttpParseAuthorityChar (
   @param[in]   UrlThe pointer to a HTTP URL string.
   @param[in]   FoundAtTRUE if there is an at sign ('@') in the 
authority component.
   @param[in, out]  UrlParser  Pointer to the buffer of the parse result.
 
   @retval EFI_SUCCESS Successfully parse the authority.
-  @retval Other   Error happened.
+  @retval EFI_INVALID_PARAMETER   The Url is invalid to parse the authority 
component.
 
 **/
 EFI_STATUS
 NetHttpParseAuthority (
   IN  CHAR8  *Url,
@@ -569,11 +569,11 @@ HttpUrlGetIp4 (
   }
 
   Parser = (HTTP_URL_PARSER*) UrlParser;
 
   if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_HOST)) == 0) {
-return EFI_INVALID_PARAMETER;
+return EFI_NOT_FOUND;
   }
 
   Ip4String = AllocatePool (Parser->FieldData[HTTP_URI_FIELD_HOST].Length + 1);
   if (Ip4String == NULL) {
 return EFI_OUT_OF_RESOURCES;
@@ -632,11 +632,11 @@ HttpUrlGetIp6 (
   }
 
   Parser = (HTTP_URL_PARSER*) UrlParser;
 
   if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_HOST)) == 0) {
-return EFI_INVALID_PARAMETER;
+return EFI_NOT_FOUND;
   }
 
   //
   // IP-literal = "[" ( IPv6address / IPvFuture  ) "]"
   //
@@ -711,11 +711,11 @@ HttpUrlGetPort (
   Index = 0;
 
   Parser = (HTTP_URL_PARSER*) UrlParser;
 
   if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_PORT)) == 0) {
-return EFI_INVALID_PARAMETER;
+return EFI_NOT_FOUND;
   }
 
   PortString = AllocatePool (Parser->FieldData[HTTP_URI_FIELD_PORT].Length + 
1);
   if (PortString == NULL) {
 return EFI_OUT_OF_RESOURCES;
@@ -1130,11 +1130,12 @@ HttpInitMsgParser (
   @param[in] BodyLength   Length in bytes of the Body.
   @param[in] Body Pointer to the buffer of the 
message-body to be parsed.
 
   @retval EFI_SUCCESSSuccessfully parse the message-body.
   @retval EFI_INVALID_PARAMETER  MsgParser is NULL or Body is NULL or 
BodyLength is 0.
-  @retval Others Operation aborted.
+  @retval EFI_ABORTEDOperation aborted.
+  @retval Other  Error happened while parsing message body.
 
 **/
 EFI_STATUS
 EFIAPI
 HttpParseMessageBody (
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 5/5] MdeModulePkg/DxeHttpLib: Refine some coding style.

2017-12-25 Thread Jiaxin Wu
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wang Fan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdeModulePkg/Include/Library/HttpLib.h   |   4 +-
 MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c | 118 +--
 2 files changed, 60 insertions(+), 62 deletions(-)

diff --git a/MdeModulePkg/Include/Library/HttpLib.h 
b/MdeModulePkg/Include/Library/HttpLib.h
index 285a831..9975aea 100644
--- a/MdeModulePkg/Include/Library/HttpLib.h
+++ b/MdeModulePkg/Include/Library/HttpLib.h
@@ -432,13 +432,13 @@ HttpFreeHeaderFields (
   @param[in]   UrlThe URL of a remote host.
   @param[out]  RequestMsg Pointer to the created HTTP request message.
   NULL if any error occured.
   @param[out]  RequestMsgSize Size of the RequestMsg (in bytes).
 
-  @return EFI_SUCCESS If HTTP request string was created 
successfully
+  @retval EFI_SUCCESS If HTTP request string was created 
successfully.
   @retval EFI_OUT_OF_RESOURCESFailed to allocate resources.
-  @retval EFI_INVALID_PARAMETER   The input arguments are invalid
+  @retval EFI_INVALID_PARAMETER   The input arguments are invalid.
 
 **/
 EFI_STATUS
 EFIAPI
 HttpGenRequestMessage (
diff --git a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c 
b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
index 327ca9e..4e5cf84 100644
--- a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
+++ b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
@@ -53,11 +53,12 @@ UriPercentDecode (
   Index = 0;
   Offset = 0;
   HexStr[2] = '\0';
   while (Index < BufferLength) {
 if (Buffer[Index] == '%') {
-  if (Index + 1 >= BufferLength || Index + 2 >= BufferLength || 
!NET_IS_HEX_CHAR (Buffer[Index+1]) || !NET_IS_HEX_CHAR (Buffer[Index+2])) {
+  if (Index + 1 >= BufferLength || Index + 2 >= BufferLength || 
+  !NET_IS_HEX_CHAR (Buffer[Index+1]) || !NET_IS_HEX_CHAR 
(Buffer[Index+2])) {
 return EFI_INVALID_PARAMETER;
   }
   HexStr[0] = Buffer[Index+1];
   HexStr[1] = Buffer[Index+2];
   ResultBuffer[Offset] = (CHAR8) AsciiStrHexToUintn (HexStr);
@@ -506,11 +507,11 @@ HttpUrlGetHostName (
 
   if (Url == NULL || UrlParser == NULL || HostName == NULL) {
 return EFI_INVALID_PARAMETER;
   }
 
-  Parser = (HTTP_URL_PARSER*) UrlParser;
+  Parser = (HTTP_URL_PARSER *) UrlParser;
 
   if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_HOST)) == 0) {
 return EFI_NOT_FOUND;
   }
 
@@ -566,11 +567,11 @@ HttpUrlGetIp4 (
   
   if (Url == NULL || UrlParser == NULL || Ip4Address == NULL) {
 return EFI_INVALID_PARAMETER;
   }
 
-  Parser = (HTTP_URL_PARSER*) UrlParser;
+  Parser = (HTTP_URL_PARSER *) UrlParser;
 
   if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_HOST)) == 0) {
 return EFI_NOT_FOUND;
   }
 
@@ -629,11 +630,11 @@ HttpUrlGetIp6 (
   
   if (Url == NULL || UrlParser == NULL || Ip6Address == NULL) {
 return EFI_INVALID_PARAMETER;
   }
 
-  Parser = (HTTP_URL_PARSER*) UrlParser;
+  Parser = (HTTP_URL_PARSER *) UrlParser;
 
   if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_HOST)) == 0) {
 return EFI_NOT_FOUND;
   }
 
@@ -694,25 +695,25 @@ HttpUrlGetPort (
   IN  CHAR8  *Url,
   IN  VOID   *UrlParser,
  OUT  UINT16 *Port
   )
 {
-  CHAR8 *PortString;
-  EFI_STATUSStatus;
-  UINTN Index;
-  UINTN Data;
-  UINT32ResultLength;
+  CHAR8*PortString;
+  EFI_STATUS   Status;
+  UINTNIndex;
+  UINTNData;
+  UINT32   ResultLength;
   HTTP_URL_PARSER  *Parser;
 
   if (Url == NULL || UrlParser == NULL || Port == NULL) {
 return EFI_INVALID_PARAMETER;
   }
 
   *Port = 0;
   Index = 0;
 
-  Parser = (HTTP_URL_PARSER*) UrlParser;
+  Parser = (HTTP_URL_PARSER *) UrlParser;
 
   if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_PORT)) == 0) {
 return EFI_NOT_FOUND;
   }
 
@@ -786,11 +787,11 @@ HttpUrlGetPath (
 
   if (Url == NULL || UrlParser == NULL || Path == NULL) {
 return EFI_INVALID_PARAMETER;
   }
 
-  Parser = (HTTP_URL_PARSER*) UrlParser;
+  Parser = (HTTP_URL_PARSER *) UrlParser;
 
   if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_PATH)) == 0) {
 return EFI_NOT_FOUND;
   }
 
@@ -1156,21 +1157,21 @@ HttpParseMessageBody (
 
   if (MsgParser == NULL) {
 return EFI_INVALID_PARAMETER;
   }
 
-  Parser = (HTTP_BODY_PARSER*) MsgParser;
+  Parser = (HTTP_BODY_PARSER *) MsgParser;
 
   if (Parser->IgnoreBody) {
 Parser->State = BodyParserComplete;
 if (Parser->Callback != NULL) {
   Status = Parser->Callback (
- BodyParseEventOnComplete,
- Body,
- 0,
- Parser->Context
- );
+ BodyParseEventOnComplete,
+ Body,
+ 0,
+ Parser->Context
+ );
   if (EFI_ER

[edk2] [Patch 0/5] MdeModulePkg/DxeHttpLib: Fix series issues in DxeHttpLib.

2017-12-25 Thread Jiaxin Wu
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wang Fan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 

Jiaxin Wu (5):
  MdeModulePkg/DxeHttpLib: Add boundary condition check.
  MdeModulePkg/DxeHttpLib: Avoid the potential memory leak when error
happen.
  MdeModulePkg/DxeHttpLib: Check the input parameters for some APIs.
  MdeModulePkg/DxeHttpLib: Correct some return Status.
  MdeModulePkg/DxeHttpLib: Refine some coding style.

 MdeModulePkg/Include/Library/HttpLib.h   |  10 +-
 MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c | 190 +--
 2 files changed, 125 insertions(+), 75 deletions(-)

-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 1/5] MdeModulePkg/DxeHttpLib: Add boundary condition check.

2017-12-25 Thread Jiaxin Wu
This patch is to add the boundary condition check to make sure
the accessed buffer is valid.

Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wang Fan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c | 39 
 1 file changed, 34 insertions(+), 5 deletions(-)

diff --git a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c 
b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
index caddbb7..4d353d7 100644
--- a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
+++ b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
@@ -33,11 +33,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
   @retval EFI_SUCCESSSuccessfully decoded the URI.
   @retval EFI_INVALID_PARAMETER  Buffer is not a valid percent-encoded string.
   
 **/
 EFI_STATUS
-EFIAPI
 UriPercentDecode (
   IN  CHAR8*Buffer,
   IN  UINT32BufferLength,
  OUT  CHAR8*ResultBuffer,
  OUT  UINT32   *ResultLength
@@ -54,11 +53,11 @@ UriPercentDecode (
   Index = 0;
   Offset = 0;
   HexStr[2] = '\0';
   while (Index < BufferLength) {
 if (Buffer[Index] == '%') {
-  if (!NET_IS_HEX_CHAR (Buffer[Index+1]) || !NET_IS_HEX_CHAR 
(Buffer[Index+2])) {
+  if (Index + 1 >= BufferLength || Index + 2 >= BufferLength || 
!NET_IS_HEX_CHAR (Buffer[Index+1]) || !NET_IS_HEX_CHAR (Buffer[Index+2])) {
 return EFI_INVALID_PARAMETER;
   }
   HexStr[0] = Buffer[Index+1];
   HexStr[1] = Buffer[Index+2];
   ResultBuffer[Offset] = (CHAR8) AsciiStrHexToUintn (HexStr);
@@ -1556,20 +1555,31 @@ HttpGetFieldNameAndValue (
   )
 {
   CHAR8  *FieldNameStr;
   CHAR8  *FieldValueStr;
   CHAR8  *StrPtr;
+  CHAR8  *EndofHeader;
 
   if (String == NULL || FieldName == NULL || FieldValue == NULL) {
 return NULL;
   }
 
   *FieldName= NULL;
   *FieldValue   = NULL;
   FieldNameStr  = NULL;
   FieldValueStr = NULL;
   StrPtr= NULL;
+  EndofHeader   = NULL;
+
+
+  //
+  // Check whether the raw HTTP header string is valid or not.
+  //
+  EndofHeader = AsciiStrStr (String, "\r\n\r\n");
+  if (EndofHeader == NULL) {
+return NULL;
+  }
 
   //
   // Each header field consists of a name followed by a colon (":") and the 
field value.
   //
   FieldNameStr = String;
@@ -1583,17 +1593,36 @@ HttpGetFieldNameAndValue (
   //
   *(FieldValueStr - 1) = 0;
 
   //
   // The field value MAY be preceded by any amount of LWS, though a single SP 
is preferred.
+  // Note: LWS  = [CRLF] 1*(SP|HT), it can be '\r\n ' or '\r\n\t' or ' ' or 
'\t'.
+  //   CRLF = '\r\n'.
+  //   SP   = ' '.
+  //   HT   = '\t' (Tab).
   //
   while (TRUE) {
 if (*FieldValueStr == ' ' || *FieldValueStr == '\t') {
+  //
+  // Boundary condition check. 
+  //
+  if ((UINTN)EndofHeader - (UINTN)(FieldValueStr) < 1) {
+return NULL;  
+  }
+  
   FieldValueStr ++;
-} else if (*FieldValueStr == '\r' && *(FieldValueStr + 1) == '\n' &&
-   (*(FieldValueStr + 2) == ' ' || *(FieldValueStr + 2) == '\t')) {
-  FieldValueStr = FieldValueStr + 3;
+} else if (*FieldValueStr == '\r') {
+  //
+  // Boundary condition check. 
+  //
+  if ((UINTN)EndofHeader - (UINTN)(FieldValueStr) < 3) {
+return NULL;  
+  }
+
+  if (*(FieldValueStr + 1) == '\n' && (*(FieldValueStr + 2) == ' ' || 
*(FieldValueStr + 2) == '\t')) {
+FieldValueStr = FieldValueStr + 3;
+  }
 } else {
   break;
 }
   }
 
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 1/5 v2] MdeModulePkg/DxeHttpLib: Add boundary condition check.

2017-12-25 Thread Jiaxin Wu
v2:
* Fix GCC the build error.

This patch is to add the boundary condition check to make sure
the accessed buffer is valid.

Cc: Gary Lin 
Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wang Fan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c | 38 +---
 1 file changed, 34 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c 
b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
index caddbb7..915b81d 100644
--- a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
+++ b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
@@ -54,11 +54,11 @@ UriPercentDecode (
   Index = 0;
   Offset = 0;
   HexStr[2] = '\0';
   while (Index < BufferLength) {
 if (Buffer[Index] == '%') {
-  if (!NET_IS_HEX_CHAR (Buffer[Index+1]) || !NET_IS_HEX_CHAR 
(Buffer[Index+2])) {
+  if (Index + 1 >= BufferLength || Index + 2 >= BufferLength || 
!NET_IS_HEX_CHAR (Buffer[Index+1]) || !NET_IS_HEX_CHAR (Buffer[Index+2])) {
 return EFI_INVALID_PARAMETER;
   }
   HexStr[0] = Buffer[Index+1];
   HexStr[1] = Buffer[Index+2];
   ResultBuffer[Offset] = (CHAR8) AsciiStrHexToUintn (HexStr);
@@ -1556,20 +1556,31 @@ HttpGetFieldNameAndValue (
   )
 {
   CHAR8  *FieldNameStr;
   CHAR8  *FieldValueStr;
   CHAR8  *StrPtr;
+  CHAR8  *EndofHeader;
 
   if (String == NULL || FieldName == NULL || FieldValue == NULL) {
 return NULL;
   }
 
   *FieldName= NULL;
   *FieldValue   = NULL;
   FieldNameStr  = NULL;
   FieldValueStr = NULL;
   StrPtr= NULL;
+  EndofHeader   = NULL;
+
+
+  //
+  // Check whether the raw HTTP header string is valid or not.
+  //
+  EndofHeader = AsciiStrStr (String, "\r\n\r\n");
+  if (EndofHeader == NULL) {
+return NULL;
+  }
 
   //
   // Each header field consists of a name followed by a colon (":") and the 
field value.
   //
   FieldNameStr = String;
@@ -1583,17 +1594,36 @@ HttpGetFieldNameAndValue (
   //
   *(FieldValueStr - 1) = 0;
 
   //
   // The field value MAY be preceded by any amount of LWS, though a single SP 
is preferred.
+  // Note: LWS  = [CRLF] 1*(SP|HT), it can be '\r\n ' or '\r\n\t' or ' ' or 
'\t'.
+  //   CRLF = '\r\n'.
+  //   SP   = ' '.
+  //   HT   = '\t' (Tab).
   //
   while (TRUE) {
 if (*FieldValueStr == ' ' || *FieldValueStr == '\t') {
+  //
+  // Boundary condition check. 
+  //
+  if ((UINTN)EndofHeader - (UINTN)(FieldValueStr) < 1) {
+return NULL;  
+  }
+  
   FieldValueStr ++;
-} else if (*FieldValueStr == '\r' && *(FieldValueStr + 1) == '\n' &&
-   (*(FieldValueStr + 2) == ' ' || *(FieldValueStr + 2) == '\t')) {
-  FieldValueStr = FieldValueStr + 3;
+} else if (*FieldValueStr == '\r') {
+  //
+  // Boundary condition check. 
+  //
+  if ((UINTN)EndofHeader - (UINTN)(FieldValueStr) < 3) {
+return NULL;  
+  }
+
+  if (*(FieldValueStr + 1) == '\n' && (*(FieldValueStr + 2) == ' ' || 
*(FieldValueStr + 2) == '\t')) {
+FieldValueStr = FieldValueStr + 3;
+  }
 } else {
   break;
 }
   }
 
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 0/2] NetworkPkg/HttpDxe: Fix some issues in HttpDxe

2017-12-25 Thread Jiaxin Wu
Cc: Wang Fan 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 

Jiaxin Wu (2):
  NetworkPkg/HttpDxe: Fix the memory leak issue in HttpRequest().
  NetworkPkg/HttpDxe: Remove the unnecessary ASSERT.

 NetworkPkg/HttpDxe/HttpImpl.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 2/2] NetworkPkg/HttpDxe: Remove the unnecessary ASSERT.

2017-12-25 Thread Jiaxin Wu
Cc: Wang Fan 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/HttpDxe/HttpImpl.c | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
index fe1c3b7..b3a64cf 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.c
+++ b/NetworkPkg/HttpDxe/HttpImpl.c
@@ -63,11 +63,10 @@ EfiHttpGetModeData (
   if ((This == NULL) || (HttpConfigData == NULL)) {
 return EFI_INVALID_PARAMETER;
   }
 
   HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (This);
-  ASSERT (HttpInstance != NULL);
 
   if ((HttpConfigData->AccessPoint.IPv6Node == NULL) ||
   (HttpConfigData->AccessPoint.IPv4Node == NULL)) {
 return EFI_INVALID_PARAMETER;
   }
@@ -147,11 +146,11 @@ EfiHttpConfigure (
 (!HttpConfigData->LocalAddressIsIPv6 && 
HttpConfigData->AccessPoint.IPv4Node == NULL {
 return EFI_INVALID_PARAMETER;
   }
 
   HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (This);
-  ASSERT (HttpInstance != NULL && HttpInstance->Service != NULL);
+  ASSERT (HttpInstance->Service != NULL);
 
   if (HttpConfigData != NULL) {
 
 if (HttpConfigData->HttpVersion >= HttpVersionUnsupported) {
   return EFI_UNSUPPORTED;
@@ -289,11 +288,10 @@ EfiHttpRequest (
   (Request->Method != HttpMethodPost) && (Request->Method != 
HttpMethodPatch)) {
 return EFI_UNSUPPORTED;
   }
 
   HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (This);
-  ASSERT (HttpInstance != NULL);
 
   //
   // Capture the method into HttpInstance.
   //
   if (Request != NULL) {
@@ -623,12 +621,10 @@ EfiHttpRequest (
 
   if (EFI_ERROR (Status) || NULL == RequestMsg) {
 goto Error3;
   }
 
-  ASSERT (RequestMsg != NULL);
-
   //
   // Every request we insert a TxToken and a response call would remove the 
TxToken.
   // In cases of PUT/POST/PATCH, after an initial request-response pair, we 
would do a
   // continuous request without a response call. So, in such cases, where 
Request
   // structure is NULL, we would not insert a TxToken.
@@ -885,11 +881,10 @@ EfiHttpCancel (
   if (This == NULL) {
 return EFI_INVALID_PARAMETER;
   }
 
   HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (This);
-  ASSERT (HttpInstance != NULL);
 
   if (HttpInstance->State != HTTP_STATE_TCP_CONNECTED) {
 return EFI_NOT_STARTED;
   }
 
@@ -1543,11 +1538,10 @@ EfiHttpResponse (
   if (HttpMsg == NULL) {
 return EFI_INVALID_PARAMETER;
   }
   
   HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (This);
-  ASSERT (HttpInstance != NULL);
 
   if (HttpInstance->State != HTTP_STATE_TCP_CONNECTED) {
 return EFI_NOT_STARTED;
   }
 
@@ -1639,11 +1633,10 @@ EfiHttpPoll (
   if (This == NULL) {
 return EFI_INVALID_PARAMETER;
   }
 
   HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (This);
-  ASSERT (HttpInstance != NULL);
 
   if (HttpInstance->State != HTTP_STATE_TCP_CONNECTED) {
 return EFI_NOT_STARTED;
   }
   
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 1/2] NetworkPkg/HttpDxe: Fix the memory leak issue in HttpRequest().

2017-12-25 Thread Jiaxin Wu
Cc: Wang Fan 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/HttpDxe/HttpImpl.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
index 57fa39f..fe1c3b7 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.c
+++ b/NetworkPkg/HttpDxe/HttpImpl.c
@@ -470,10 +470,12 @@ EfiHttpRequest (
 
   Wrap->TcpWrap.Method = Request->Method;
 
   FreePool (HostName);
 
+  HttpUrlFreeParser (UrlParser);
+
   //
   // Queue the HTTP token and return.
   //
   return EFI_SUCCESS;
 } else {
@@ -654,10 +656,14 @@ EfiHttpRequest (
   DispatchDpc ();
   
   if (HostName != NULL) {
 FreePool (HostName);
   }
+
+  if (UrlParser != NULL) {
+HttpUrlFreeParser (UrlParser);
+  }
   
   return EFI_SUCCESS;
 
 Error5:
   //
@@ -697,11 +703,11 @@ Error1:
 FreePool (HostName);
   }
   if (Wrap != NULL) {
 FreePool (Wrap);
   }
-  if (UrlParser!= NULL) {
+  if (UrlParser != NULL) {
 HttpUrlFreeParser (UrlParser);
   }
 
   return Status;
   
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 3/3] NetworkPkg/TcpDxe: Check TCP payload for release version.

2017-12-25 Thread Jiaxin Wu
TCP payload check is implemented by TcpVerifySegment(), but all the function
calls of TcpVerifySegment() are placed in ASSERT(), which is only valid for
debug version:
  ASSERT (TcpVerifySegment (Nbuf) != 0);

This patch is to enable the check for release version.

Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Wang Fan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/TcpDxe/TcpInput.c  | 125 +-
 NetworkPkg/TcpDxe/TcpOutput.c |  29 +++---
 2 files changed, 122 insertions(+), 32 deletions(-)

diff --git a/NetworkPkg/TcpDxe/TcpInput.c b/NetworkPkg/TcpDxe/TcpInput.c
index f8845dc..92a0ab8 100644
--- a/NetworkPkg/TcpDxe/TcpInput.c
+++ b/NetworkPkg/TcpDxe/TcpInput.c
@@ -279,12 +279,15 @@ TcpComputeRtt (
 
   @param[in]  Nbuf The buffer that contains a received TCP segment without 
an IP header.
   @param[in]  Left The sequence number of the window's left edge.
   @param[in]  RightThe sequence number of the window's right edge.
 
+  @retval 0The segment is broken.
+  @retval 1The segment is in good shape.
+
 **/
-VOID
+INTN
 TcpTrimSegment (
   IN NET_BUF   *Nbuf,
   IN TCP_SEQNO Left,
   IN TCP_SEQNO Right
   )
@@ -304,11 +307,11 @@ TcpTrimSegment (
 TCP_CLEAR_FLG (Seg->Flag, TCP_FLG_SYN);
 TCP_CLEAR_FLG (Seg->Flag, TCP_FLG_FIN);
 
 Seg->Seq = Seg->End;
 NetbufTrim (Nbuf, Nbuf->TotalSize, NET_BUF_HEAD);
-return;
+return 1;
   }
 
   //
   // Adjust the buffer header
   //
@@ -357,27 +360,30 @@ TcpTrimSegment (
 if (Drop != 0) {
   NetbufTrim (Nbuf, Drop, NET_BUF_TAIL);
 }
   }
 
-  ASSERT (TcpVerifySegment (Nbuf) != 0);
+  return TcpVerifySegment (Nbuf);
 }
 
 /**
   Trim off the data outside the tcb's receive window.
 
   @param[in]  Tcb  Pointer to the TCP_CB of this TCP instance.
   @param[in]  Nbuf Pointer to the NET_BUF containing the received tcp 
segment.
 
+  @retval 0The segment is broken.
+  @retval 1The segment is in good shape.
+
 **/
-VOID
+INTN
 TcpTrimInWnd (
   IN TCP_CB  *Tcb,
   IN NET_BUF *Nbuf
   )
 {
-  TcpTrimSegment (Nbuf, Tcb->RcvNxt, Tcb->RcvWl2 + Tcb->RcvWnd);
+  return TcpTrimSegment (Nbuf, Tcb->RcvNxt, Tcb->RcvWl2 + Tcb->RcvWnd);
 }
 
 /**
   Process the data and FIN flag, and check whether to deliver
   data to the socket layer.
@@ -419,11 +425,20 @@ TcpDeliverData (
 
   while (Entry != &Tcb->RcvQue) {
 Nbuf  = NET_LIST_USER_STRUCT (Entry, NET_BUF, List);
 Seg   = TCPSEG_NETBUF (Nbuf);
 
-ASSERT (TcpVerifySegment (Nbuf) != 0);
+if (TcpVerifySegment (Nbuf) == 0) {
+  DEBUG (
+(EFI_D_ERROR,
+"TcpToSendData: discard a broken segment for TCB %p\n",
+Tcb)
+);
+  NetbufFree (Nbuf);
+  return -1;
+}
+
 ASSERT (Nbuf->Tcp == NULL);
 
 if (TCP_SEQ_GT (Seg->Seq, Seq)) {
   break;
 }
@@ -559,12 +574,15 @@ TcpDeliverData (
   Store the data into the reassemble queue.
 
   @param[in, out]  Tcb   Pointer to the TCP_CB of this TCP instance.
   @param[in]   Nbuf  Pointer to the buffer containing the data to be 
queued.
 
+  @retval  0 An error condition occurred.
+  @retval  1 No error occurred to queue data.
+
 **/
-VOID
+INTN
 TcpQueueData (
   IN OUT TCP_CB  *Tcb,
   IN NET_BUF *Nbuf
   )
 {
@@ -586,11 +604,11 @@ TcpQueueData (
   // no out-of-order segments are received.
   //
   if (IsListEmpty (Head)) {
 
 InsertTailList (Head, &Nbuf->List);
-return;
+return 1;
   }
 
   //
   // Find the point to insert the buffer
   //
@@ -613,16 +631,16 @@ TcpQueueData (
 Node = NET_LIST_USER_STRUCT (Prev, NET_BUF, List);
 
 if (TCP_SEQ_LT (Seg->Seq, TCPSEG_NETBUF (Node)->End)) {
 
   if (TCP_SEQ_LEQ (Seg->End, TCPSEG_NETBUF (Node)->End)) {
-
-NetbufFree (Nbuf);
-return;
+return 1;
   }
 
-  TcpTrimSegment (Nbuf, TCPSEG_NETBUF (Node)->End, Seg->End);
+  if (TcpTrimSegment (Nbuf, TCPSEG_NETBUF (Node)->End, Seg->End) == 0) {
+return 0;
+  }
 }
   }
 
   InsertHeadList (Prev, &Nbuf->List);
 
@@ -646,31 +664,38 @@ TcpQueueData (
 if (TCP_SEQ_LT (TCPSEG_NETBUF (Node)->Seq, Seg->End)) {
 
   if (TCP_SEQ_LEQ (TCPSEG_NETBUF (Node)->Seq, Seg->Seq)) {
 
 RemoveEntryList (&Nbuf->List);
-NetbufFree (Nbuf);
-return;
+return 1;
   }
 
-  TcpTrimSegment (Nbuf, Seg->Seq, TCPSEG_NETBUF (Node)->Seq);
+  if (TcpTrimSegment (Nbuf, Seg->Seq, TCPSEG_NETBUF (Node)->Seq) == 0) {
+RemoveEntryList (&Nbuf->List);
+return 0;
+  }
   break;
 }
 
 Cur = Cur->ForwardLink;
   }
+
+  return 1;
 }
 
 
 /**
   Adjust the send queue or the retransmit queue.
 
   @param[in]  Tcb  Pointer to the TCP_CB of this TCP instance.
   @param[in]  Ack  The acknowledge seuqence number of the received segment.
 
+  @retval  0 An error condition occurred.
+  @retval  1 No e

[edk2] [Patch] NetworkPkg/HttpDxe: Fix build warning error if CHAR8 is unsigned.

2018-01-01 Thread Jiaxin Wu
This patch is to fix the compiler warning error: C4245. The issue will happen
if the below build option is enabled:
  *_*_*_CC_FLAGS = -J.

That's because the value of ('A' - 'a') is a negative value, which will
be converted to an unsigned type if CHAR8 is treated as unsigned:
  Src -= ('A' - 'a');

The above issue is also recorded at:
https://bugzilla.tianocore.org/show_bug.cgi?id=815.

Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Michael Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/HttpDxe/HttpsSupport.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/NetworkPkg/HttpDxe/HttpsSupport.c 
b/NetworkPkg/HttpDxe/HttpsSupport.c
index e6f4d5a..6aed61a 100644
--- a/NetworkPkg/HttpDxe/HttpsSupport.c
+++ b/NetworkPkg/HttpDxe/HttpsSupport.c
@@ -65,15 +65,15 @@ AsciiStrCaseStr (
 && (*String != '\0')) {
   Src = *String;
   Dst = *SearchStringTmp;
 
   if ((Src >= 'A') && (Src <= 'Z')) {
-Src -= ('A' - 'a');
+Src += ('a' - 'A');
   }
 
   if ((Dst >= 'A') && (Dst <= 'Z')) {
-Dst -= ('A' - 'a');
+Dst += ('a' - 'A');
   }
 
   if (Src != Dst) {
 break;
   }
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 2/2] NetworkPkg/IScsiDxe: Remove unnecessary close for ExitBootServiceEvent.

2018-01-01 Thread Jiaxin Wu
The close for ExitBootServiceEvent in IScsiOnExitBootService callback
function is unnecessary since it will be closed in ISCSI driver stop()
function, which is invoked when the transition from BS to RT.

This issue is recorded at
https://bugzilla.tianocore.org/show_bug.cgi?id=742.

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/IScsiDxe/IScsiMisc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMisc.c
index 9e4164c..cfa8b29 100644
--- a/NetworkPkg/IScsiDxe/IScsiMisc.c
+++ b/NetworkPkg/IScsiDxe/IScsiMisc.c
@@ -1,9 +1,9 @@
 /** @file
   Miscellaneous routines for iSCSI driver.
 
-Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -2483,12 +2483,11 @@ IScsiOnExitBootService (
   )
 {
   ISCSI_DRIVER_DATA *Private;
 
   Private = (ISCSI_DRIVER_DATA *) Context;
-  gBS->CloseEvent (Private->ExitBootServiceEvent);
-
+  
   if (Private->Session != NULL) {
 IScsiSessionAbort (Private->Session);
   }
 }
 
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 0/2] IScsiDxe: Remove unnecessary close for ExitBootServiceEvent.

2018-01-01 Thread Jiaxin Wu
The close for ExitBootServiceEvent in IScsiOnExitBootService callback
function is unnecessary since it will be closed in ISCSI driver stop()
function, which is invoked when the transition from BS to RT.

This issue is recorded at
https://bugzilla.tianocore.org/show_bug.cgi?id=742.

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 

Jiaxin Wu (2):
  MdeModulePkg/IScsiDxe: Remove unnecessary close for
ExitBootServiceEvent.
  NetworkPkg/IScsiDxe: Remove unnecessary close for
ExitBootServiceEvent.

 MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c | 3 +--
 NetworkPkg/IScsiDxe/IScsiMisc.c | 5 ++---
 2 files changed, 3 insertions(+), 5 deletions(-)

-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 1/2] MdeModulePkg/IScsiDxe: Remove unnecessary close for ExitBootServiceEvent.

2018-01-01 Thread Jiaxin Wu
The close for ExitBootServiceEvent in IScsiOnExitBootService callback
function is unnecessary since it will be closed in ISCSI driver stop()
function, which is invoked when the transition from BS to RT.

This issue is recorded at
https://bugzilla.tianocore.org/show_bug.cgi?id=742.

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c 
b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
index ae202c3..166fb4d 100644
--- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
+++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
@@ -1,9 +1,9 @@
 /** @file
   Miscellaneous routines for iSCSI driver.
 
-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -870,11 +870,10 @@ IScsiOnExitBootService (
   )
 {
   ISCSI_DRIVER_DATA *Private;
 
   Private = (ISCSI_DRIVER_DATA *) Context;
-  gBS->CloseEvent (Private->ExitBootServiceEvent);
 
   IScsiSessionAbort (&Private->Session);
 }
 
 /**
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


<    1   2   3   4   5   >