public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch V2] NetworkPkg: Print error message to screen if error occurs during HTTP boot.
@ 2017-11-15  1:51 Fu Siyuan
  2017-11-15  3:13 ` Ye, Ting
  2017-11-15  5:56 ` Wu, Jiaxin
  0 siblings, 2 replies; 3+ messages in thread
From: Fu Siyuan @ 2017-11-15  1:51 UTC (permalink / raw)
  To: edk2-devel; +Cc: Wu Jiaxin, Ye Ting

V2 update:
Add error message is URI address is not correct.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
---
 NetworkPkg/HttpBootDxe/HttpBootImpl.c    | 21 +++++++++++++++++++++
 NetworkPkg/HttpBootDxe/HttpBootSupport.c |  2 ++
 NetworkPkg/HttpDxe/HttpImpl.c            |  1 +
 3 files changed, 24 insertions(+)

diff --git a/NetworkPkg/HttpBootDxe/HttpBootImpl.c b/NetworkPkg/HttpBootDxe/HttpBootImpl.c
index 06a8a6a..d591db5 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootImpl.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootImpl.c
@@ -327,6 +327,7 @@ HttpBootLoadFile (
     //
     Status = HttpBootDiscoverBootInfo (Private);
     if (EFI_ERROR (Status)) {
+      AsciiPrint ("\n  Error: Could not discover the boot information for DHCP server.\n");
       goto ON_EXIT;
     }
   }
@@ -369,6 +370,7 @@ HttpBootLoadFile (
                  &Private->ImageType
                  );
       if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) {
+        AsciiPrint ("\n  Error: Could not retrieve NBP file size from HTTP server.\n");
         goto ON_EXIT;
       }
     }
@@ -394,6 +396,22 @@ HttpBootLoadFile (
   
 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");
+  }
   return Status;
 }
 
@@ -555,6 +573,7 @@ HttpBootDxeLoadFile (
   MediaPresent = TRUE;
   NetLibDetectMedia (Private->Controller, &MediaPresent);
   if (!MediaPresent) {
+    AsciiPrint ("\n  Error: Could not detect network connection.\n");
     return EFI_NO_MEDIA;
   }
   
@@ -595,6 +614,8 @@ HttpBootDxeLoadFile (
     Status = HttpBootRegisterRamDisk (Private, *BufferSize, Buffer, ImageType);
     if (!EFI_ERROR (Status)) {
       Status = EFI_WARN_FILE_SYSTEM;
+    } else {
+      AsciiPrint ("\n  Error: Could not register RAM disk to the system.\n");
     }
   }
 
diff --git a/NetworkPkg/HttpBootDxe/HttpBootSupport.c b/NetworkPkg/HttpBootDxe/HttpBootSupport.c
index d508e2c..7ca48f3 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootSupport.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootSupport.c
@@ -1093,6 +1093,7 @@ HttpBootCheckUriScheme (
   // Return EFI_INVALID_PARAMETER if the URI is not HTTP or HTTPS.
   //
   if ((AsciiStrnCmp (Uri, "http://", 7) != 0) && (AsciiStrnCmp (Uri, "https://", 8) != 0)) {
+    AsciiPrint ("\n  Error: Invalid URI address.\n");
     DEBUG ((EFI_D_ERROR, "HttpBootCheckUriScheme: Invalid Uri.\n"));
     return EFI_INVALID_PARAMETER;
   }
@@ -1101,6 +1102,7 @@ HttpBootCheckUriScheme (
   // HTTP is disabled, return EFI_ACCESS_DENIED if the URI is HTTP.
   //
   if (!PcdGetBool (PcdAllowHttpConnections) && (AsciiStrnCmp (Uri, "http://", 7) == 0)) {
+    AsciiPrint ("\n  Error: Access forbidden, only HTTPS connection is allowed.\n");
     DEBUG ((EFI_D_ERROR, "HttpBootCheckUriScheme: HTTP is disabled.\n"));
     return EFI_ACCESS_DENIED;
   }
diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
index 46d0323..57fa39f 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.c
+++ b/NetworkPkg/HttpDxe/HttpImpl.c
@@ -523,6 +523,7 @@ EfiHttpRequest (
       
       FreePool (HostNameStr);
       if (EFI_ERROR (Status)) {
+        DEBUG ((EFI_D_ERROR, "Error: Could not retrieve the host address from DNS server.\n"));
         goto Error1;
       }
     }
-- 
1.9.5.msysgit.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Patch V2] NetworkPkg: Print error message to screen if error occurs during HTTP boot.
  2017-11-15  1:51 [Patch V2] NetworkPkg: Print error message to screen if error occurs during HTTP boot Fu Siyuan
@ 2017-11-15  3:13 ` Ye, Ting
  2017-11-15  5:56 ` Wu, Jiaxin
  1 sibling, 0 replies; 3+ messages in thread
From: Ye, Ting @ 2017-11-15  3:13 UTC (permalink / raw)
  To: Fu, Siyuan, edk2-devel@lists.01.org; +Cc: Wu, Jiaxin

Reviewed-by: Ye Ting <ting.ye@intel.com> 

-----Original Message-----
From: Fu, Siyuan 
Sent: Wednesday, November 15, 2017 9:52 AM
To: edk2-devel@lists.01.org
Cc: Wu, Jiaxin <jiaxin.wu@intel.com>; Ye, Ting <ting.ye@intel.com>
Subject: [Patch V2] NetworkPkg: Print error message to screen if error occurs during HTTP boot.

V2 update:
Add error message is URI address is not correct.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
---
 NetworkPkg/HttpBootDxe/HttpBootImpl.c    | 21 +++++++++++++++++++++
 NetworkPkg/HttpBootDxe/HttpBootSupport.c |  2 ++
 NetworkPkg/HttpDxe/HttpImpl.c            |  1 +
 3 files changed, 24 insertions(+)

diff --git a/NetworkPkg/HttpBootDxe/HttpBootImpl.c b/NetworkPkg/HttpBootDxe/HttpBootImpl.c
index 06a8a6a..d591db5 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootImpl.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootImpl.c
@@ -327,6 +327,7 @@ HttpBootLoadFile (
     //
     Status = HttpBootDiscoverBootInfo (Private);
     if (EFI_ERROR (Status)) {
+      AsciiPrint ("\n  Error: Could not discover the boot information 
+ for DHCP server.\n");
       goto ON_EXIT;
     }
   }
@@ -369,6 +370,7 @@ HttpBootLoadFile (
                  &Private->ImageType
                  );
       if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) {
+        AsciiPrint ("\n  Error: Could not retrieve NBP file size from 
+ HTTP server.\n");
         goto ON_EXIT;
       }
     }
@@ -394,6 +396,22 @@ HttpBootLoadFile (
   
 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");  }
   return Status;
 }
 
@@ -555,6 +573,7 @@ HttpBootDxeLoadFile (
   MediaPresent = TRUE;
   NetLibDetectMedia (Private->Controller, &MediaPresent);
   if (!MediaPresent) {
+    AsciiPrint ("\n  Error: Could not detect network connection.\n");
     return EFI_NO_MEDIA;
   }
   
@@ -595,6 +614,8 @@ HttpBootDxeLoadFile (
     Status = HttpBootRegisterRamDisk (Private, *BufferSize, Buffer, ImageType);
     if (!EFI_ERROR (Status)) {
       Status = EFI_WARN_FILE_SYSTEM;
+    } else {
+      AsciiPrint ("\n  Error: Could not register RAM disk to the 
+ system.\n");
     }
   }
 
diff --git a/NetworkPkg/HttpBootDxe/HttpBootSupport.c b/NetworkPkg/HttpBootDxe/HttpBootSupport.c
index d508e2c..7ca48f3 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootSupport.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootSupport.c
@@ -1093,6 +1093,7 @@ HttpBootCheckUriScheme (
   // Return EFI_INVALID_PARAMETER if the URI is not HTTP or HTTPS.
   //
   if ((AsciiStrnCmp (Uri, "http://", 7) != 0) && (AsciiStrnCmp (Uri, "https://", 8) != 0)) {
+    AsciiPrint ("\n  Error: Invalid URI address.\n");
     DEBUG ((EFI_D_ERROR, "HttpBootCheckUriScheme: Invalid Uri.\n"));
     return EFI_INVALID_PARAMETER;
   }
@@ -1101,6 +1102,7 @@ HttpBootCheckUriScheme (
   // HTTP is disabled, return EFI_ACCESS_DENIED if the URI is HTTP.
   //
   if (!PcdGetBool (PcdAllowHttpConnections) && (AsciiStrnCmp (Uri, "http://", 7) == 0)) {
+    AsciiPrint ("\n  Error: Access forbidden, only HTTPS connection is 
+ allowed.\n");
     DEBUG ((EFI_D_ERROR, "HttpBootCheckUriScheme: HTTP is disabled.\n"));
     return EFI_ACCESS_DENIED;
   }
diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c index 46d0323..57fa39f 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.c
+++ b/NetworkPkg/HttpDxe/HttpImpl.c
@@ -523,6 +523,7 @@ EfiHttpRequest (
       
       FreePool (HostNameStr);
       if (EFI_ERROR (Status)) {
+        DEBUG ((EFI_D_ERROR, "Error: Could not retrieve the host 
+ address from DNS server.\n"));
         goto Error1;
       }
     }
--
1.9.5.msysgit.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Patch V2] NetworkPkg: Print error message to screen if error occurs during HTTP boot.
  2017-11-15  1:51 [Patch V2] NetworkPkg: Print error message to screen if error occurs during HTTP boot Fu Siyuan
  2017-11-15  3:13 ` Ye, Ting
@ 2017-11-15  5:56 ` Wu, Jiaxin
  1 sibling, 0 replies; 3+ messages in thread
From: Wu, Jiaxin @ 2017-11-15  5:56 UTC (permalink / raw)
  To: Fu, Siyuan, edk2-devel@lists.01.org; +Cc: Ye, Ting

Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>


> -----Original Message-----
> From: Fu, Siyuan
> Sent: Wednesday, November 15, 2017 9:52 AM
> To: edk2-devel@lists.01.org
> Cc: Wu, Jiaxin <jiaxin.wu@intel.com>; Ye, Ting <ting.ye@intel.com>
> Subject: [Patch V2] NetworkPkg: Print error message to screen if error occurs
> during HTTP boot.
> 
> V2 update:
> Add error message is URI address is not correct.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
> Cc: Wu Jiaxin <jiaxin.wu@intel.com>
> Cc: Ye Ting <ting.ye@intel.com>
> ---
>  NetworkPkg/HttpBootDxe/HttpBootImpl.c    | 21
> +++++++++++++++++++++
>  NetworkPkg/HttpBootDxe/HttpBootSupport.c |  2 ++
>  NetworkPkg/HttpDxe/HttpImpl.c            |  1 +
>  3 files changed, 24 insertions(+)
> 
> diff --git a/NetworkPkg/HttpBootDxe/HttpBootImpl.c
> b/NetworkPkg/HttpBootDxe/HttpBootImpl.c
> index 06a8a6a..d591db5 100644
> --- a/NetworkPkg/HttpBootDxe/HttpBootImpl.c
> +++ b/NetworkPkg/HttpBootDxe/HttpBootImpl.c
> @@ -327,6 +327,7 @@ HttpBootLoadFile (
>      //
>      Status = HttpBootDiscoverBootInfo (Private);
>      if (EFI_ERROR (Status)) {
> +      AsciiPrint ("\n  Error: Could not discover the boot information for DHCP
> server.\n");
>        goto ON_EXIT;
>      }
>    }
> @@ -369,6 +370,7 @@ HttpBootLoadFile (
>                   &Private->ImageType
>                   );
>        if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) {
> +        AsciiPrint ("\n  Error: Could not retrieve NBP file size from HTTP
> server.\n");
>          goto ON_EXIT;
>        }
>      }
> @@ -394,6 +396,22 @@ HttpBootLoadFile (
> 
>  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");
> +  }
>    return Status;
>  }
> 
> @@ -555,6 +573,7 @@ HttpBootDxeLoadFile (
>    MediaPresent = TRUE;
>    NetLibDetectMedia (Private->Controller, &MediaPresent);
>    if (!MediaPresent) {
> +    AsciiPrint ("\n  Error: Could not detect network connection.\n");
>      return EFI_NO_MEDIA;
>    }
> 
> @@ -595,6 +614,8 @@ HttpBootDxeLoadFile (
>      Status = HttpBootRegisterRamDisk (Private, *BufferSize, Buffer,
> ImageType);
>      if (!EFI_ERROR (Status)) {
>        Status = EFI_WARN_FILE_SYSTEM;
> +    } else {
> +      AsciiPrint ("\n  Error: Could not register RAM disk to the system.\n");
>      }
>    }
> 
> diff --git a/NetworkPkg/HttpBootDxe/HttpBootSupport.c
> b/NetworkPkg/HttpBootDxe/HttpBootSupport.c
> index d508e2c..7ca48f3 100644
> --- a/NetworkPkg/HttpBootDxe/HttpBootSupport.c
> +++ b/NetworkPkg/HttpBootDxe/HttpBootSupport.c
> @@ -1093,6 +1093,7 @@ HttpBootCheckUriScheme (
>    // Return EFI_INVALID_PARAMETER if the URI is not HTTP or HTTPS.
>    //
>    if ((AsciiStrnCmp (Uri, "http://", 7) != 0) && (AsciiStrnCmp (Uri, "https://",
> 8) != 0)) {
> +    AsciiPrint ("\n  Error: Invalid URI address.\n");
>      DEBUG ((EFI_D_ERROR, "HttpBootCheckUriScheme: Invalid Uri.\n"));
>      return EFI_INVALID_PARAMETER;
>    }
> @@ -1101,6 +1102,7 @@ HttpBootCheckUriScheme (
>    // HTTP is disabled, return EFI_ACCESS_DENIED if the URI is HTTP.
>    //
>    if (!PcdGetBool (PcdAllowHttpConnections) && (AsciiStrnCmp (Uri,
> "http://", 7) == 0)) {
> +    AsciiPrint ("\n  Error: Access forbidden, only HTTPS connection is
> allowed.\n");
>      DEBUG ((EFI_D_ERROR, "HttpBootCheckUriScheme: HTTP is disabled.\n"));
>      return EFI_ACCESS_DENIED;
>    }
> diff --git a/NetworkPkg/HttpDxe/HttpImpl.c
> b/NetworkPkg/HttpDxe/HttpImpl.c
> index 46d0323..57fa39f 100644
> --- a/NetworkPkg/HttpDxe/HttpImpl.c
> +++ b/NetworkPkg/HttpDxe/HttpImpl.c
> @@ -523,6 +523,7 @@ EfiHttpRequest (
> 
>        FreePool (HostNameStr);
>        if (EFI_ERROR (Status)) {
> +        DEBUG ((EFI_D_ERROR, "Error: Could not retrieve the host address
> from DNS server.\n"));
>          goto Error1;
>        }
>      }
> --
> 1.9.5.msysgit.1



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-11-15  5:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-15  1:51 [Patch V2] NetworkPkg: Print error message to screen if error occurs during HTTP boot Fu Siyuan
2017-11-15  3:13 ` Ye, Ting
2017-11-15  5:56 ` Wu, Jiaxin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox