HttpBootSupport.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /** @file
  2. Support functions declaration for UEFI HTTP boot driver.
  3. Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
  4. (C) Copyright 2020 Hewlett-Packard Development Company, L.P.<BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #ifndef __EFI_HTTP_BOOT_SUPPORT_H__
  8. #define __EFI_HTTP_BOOT_SUPPORT_H__
  9. /**
  10. Get the Nic handle using any child handle in the IPv4 stack.
  11. @param[in] ControllerHandle Pointer to child handle over IPv4.
  12. @return NicHandle The pointer to the Nic handle.
  13. @return NULL Can't find the Nic handle.
  14. **/
  15. EFI_HANDLE
  16. HttpBootGetNicByIp4Children (
  17. IN EFI_HANDLE ControllerHandle
  18. );
  19. /**
  20. Get the Nic handle using any child handle in the IPv6 stack.
  21. @param[in] ControllerHandle Pointer to child handle over IPv6.
  22. @return NicHandle The pointer to the Nic handle.
  23. @return NULL Can't find the Nic handle.
  24. **/
  25. EFI_HANDLE
  26. HttpBootGetNicByIp6Children (
  27. IN EFI_HANDLE ControllerHandle
  28. );
  29. /**
  30. This function is to convert UINTN to ASCII string with the required formatting.
  31. @param[in] Number Numeric value to be converted.
  32. @param[in] Buffer The pointer to the buffer for ASCII string.
  33. @param[in] Length The length of the required format.
  34. **/
  35. VOID
  36. HttpBootUintnToAscDecWithFormat (
  37. IN UINTN Number,
  38. IN UINT8 *Buffer,
  39. IN INTN Length
  40. );
  41. /**
  42. This function is to display the IPv4 address.
  43. @param[in] Ip The pointer to the IPv4 address.
  44. **/
  45. VOID
  46. HttpBootShowIp4Addr (
  47. IN EFI_IPv4_ADDRESS *Ip
  48. );
  49. /**
  50. This function is to display the IPv6 address.
  51. @param[in] Ip The pointer to the IPv6 address.
  52. **/
  53. VOID
  54. HttpBootShowIp6Addr (
  55. IN EFI_IPv6_ADDRESS *Ip
  56. );
  57. /**
  58. This function is to display the HTTP error status.
  59. @param[in] StatusCode The status code value in HTTP message.
  60. **/
  61. VOID
  62. HttpBootPrintErrorMessage (
  63. EFI_HTTP_STATUS_CODE StatusCode
  64. );
  65. /**
  66. Retrieve the host address using the EFI_DNS6_PROTOCOL.
  67. @param[in] Private The pointer to the driver's private data.
  68. @param[in] HostName Pointer to buffer containing hostname.
  69. @param[out] IpAddress On output, pointer to buffer containing IPv6 address.
  70. @retval EFI_SUCCESS Operation succeeded.
  71. @retval EFI_DEVICE_ERROR An unexpected network error occurred.
  72. @retval Others Other errors as indicated.
  73. **/
  74. EFI_STATUS
  75. HttpBootDns (
  76. IN HTTP_BOOT_PRIVATE_DATA *Private,
  77. IN CHAR16 *HostName,
  78. OUT EFI_IPv6_ADDRESS *IpAddress
  79. );
  80. /**
  81. Notify the callback function when an event is triggered.
  82. @param[in] Event The triggered event.
  83. @param[in] Context The opaque parameter to the function.
  84. **/
  85. VOID
  86. EFIAPI
  87. HttpBootCommonNotify (
  88. IN EFI_EVENT Event,
  89. IN VOID *Context
  90. );
  91. /**
  92. This function checks the HTTP(S) URI scheme.
  93. @param[in] Uri The pointer to the URI string.
  94. @retval EFI_SUCCESS The URI scheme is valid.
  95. @retval EFI_INVALID_PARAMETER The URI scheme is not HTTP or HTTPS.
  96. @retval EFI_ACCESS_DENIED HTTP is disabled and the URI is HTTP.
  97. **/
  98. EFI_STATUS
  99. HttpBootCheckUriScheme (
  100. IN CHAR8 *Uri
  101. );
  102. /**
  103. Get the URI address string from the input device path.
  104. Caller need to free the buffer in the UriAddress pointer.
  105. @param[in] FilePath Pointer to the device path which contains a URI device path node.
  106. @param[out] UriAddress The URI address string extract from the device path.
  107. @retval EFI_SUCCESS The URI string is returned.
  108. @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
  109. **/
  110. EFI_STATUS
  111. HttpBootParseFilePath (
  112. IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
  113. OUT CHAR8 **UriAddress
  114. );
  115. /**
  116. This function returns the image type according to server replied HTTP message
  117. and also the image's URI info.
  118. @param[in] Uri The pointer to the image's URI string.
  119. @param[in] UriParser URI Parse result returned by NetHttpParseUrl().
  120. @param[in] HeaderCount Number of HTTP header structures in Headers list.
  121. @param[in] Headers Array containing list of HTTP headers.
  122. @param[out] ImageType The image type of the downloaded file.
  123. @retval EFI_SUCCESS The image type is returned in ImageType.
  124. @retval EFI_INVALID_PARAMETER ImageType, Uri or UriParser is NULL.
  125. @retval EFI_INVALID_PARAMETER HeaderCount is not zero, and Headers is NULL.
  126. @retval EFI_NOT_FOUND Failed to identify the image type.
  127. @retval Others Unexpected error happened.
  128. **/
  129. EFI_STATUS
  130. HttpBootCheckImageType (
  131. IN CHAR8 *Uri,
  132. IN VOID *UriParser,
  133. IN UINTN HeaderCount,
  134. IN EFI_HTTP_HEADER *Headers,
  135. OUT HTTP_BOOT_IMAGE_TYPE *ImageType
  136. );
  137. /**
  138. This function register the RAM disk info to the system.
  139. @param[in] Private The pointer to the driver's private data.
  140. @param[in] BufferSize The size of Buffer in bytes.
  141. @param[in] Buffer The base address of the RAM disk.
  142. @param[in] ImageType The image type of the file in Buffer.
  143. @retval EFI_SUCCESS The RAM disk has been registered.
  144. @retval EFI_NOT_FOUND No RAM disk protocol instances were found.
  145. @retval EFI_UNSUPPORTED The ImageType is not supported.
  146. @retval Others Unexpected error happened.
  147. **/
  148. EFI_STATUS
  149. HttpBootRegisterRamDisk (
  150. IN HTTP_BOOT_PRIVATE_DATA *Private,
  151. IN UINTN BufferSize,
  152. IN VOID *Buffer,
  153. IN HTTP_BOOT_IMAGE_TYPE ImageType
  154. );
  155. /**
  156. Indicate if the HTTP status code indicates a redirection.
  157. @param[in] StatusCode HTTP status code from server.
  158. @return TRUE if it's redirection.
  159. **/
  160. BOOLEAN
  161. HttpBootIsHttpRedirectStatusCode (
  162. IN EFI_HTTP_STATUS_CODE StatusCode
  163. );
  164. #endif