HttpBootDhcp6.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /** @file
  2. Functions declaration related with DHCPv6 for HTTP boot driver.
  3. Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef __EFI_HTTP_BOOT_DHCP6_H__
  7. #define __EFI_HTTP_BOOT_DHCP6_H__
  8. #define HTTP_BOOT_OFFER_MAX_NUM 16
  9. #define HTTP_BOOT_DHCP6_OPTION_MAX_NUM 16
  10. #define HTTP_BOOT_DHCP6_OPTION_MAX_SIZE 312
  11. #define HTTP_BOOT_DHCP6_PACKET_MAX_SIZE 1472
  12. #define HTTP_BOOT_IP6_ROUTE_TABLE_TIMEOUT 10
  13. #define HTTP_BOOT_DEFAULT_HOPLIMIT 64
  14. #define HTTP_BOOT_DEFAULT_LIFETIME 50000
  15. #define HTTP_BOOT_DHCP6_ENTERPRISE_NUM 343 // TODO: IANA TBD: temporarily using Intel's
  16. #define HTTP_BOOT_DHCP6_MAX_BOOT_FILE_SIZE 65535 // It's a limitation of bit length, 65535*512 bytes.
  17. #define HTTP_BOOT_DHCP6_IDX_IA_NA 0
  18. #define HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL 1
  19. #define HTTP_BOOT_DHCP6_IDX_BOOT_FILE_PARAM 2
  20. #define HTTP_BOOT_DHCP6_IDX_VENDOR_CLASS 3
  21. #define HTTP_BOOT_DHCP6_IDX_DNS_SERVER 4
  22. #define HTTP_BOOT_DHCP6_IDX_MAX 5
  23. #pragma pack(1)
  24. typedef struct {
  25. UINT16 OpCode[256];
  26. } HTTP_BOOT_DHCP6_OPTION_ORO;
  27. typedef struct {
  28. UINT8 Type;
  29. UINT8 MajorVer;
  30. UINT8 MinorVer;
  31. } HTTP_BOOT_DHCP6_OPTION_UNDI;
  32. typedef struct {
  33. UINT16 Type;
  34. } HTTP_BOOT_DHCP6_OPTION_ARCH;
  35. typedef struct {
  36. UINT8 ClassIdentifier[11];
  37. UINT8 ArchitecturePrefix[5];
  38. UINT8 ArchitectureType[5];
  39. UINT8 Lit3[1];
  40. UINT8 InterfaceName[4];
  41. UINT8 Lit4[1];
  42. UINT8 UndiMajor[3];
  43. UINT8 UndiMinor[3];
  44. } HTTP_BOOT_CLASS_ID;
  45. typedef struct {
  46. UINT32 Vendor;
  47. UINT16 ClassLen;
  48. HTTP_BOOT_CLASS_ID ClassId;
  49. } HTTP_BOOT_DHCP6_OPTION_VENDOR_CLASS;
  50. #pragma pack()
  51. typedef union {
  52. HTTP_BOOT_DHCP6_OPTION_ORO *Oro;
  53. HTTP_BOOT_DHCP6_OPTION_UNDI *Undi;
  54. HTTP_BOOT_DHCP6_OPTION_ARCH *Arch;
  55. HTTP_BOOT_DHCP6_OPTION_VENDOR_CLASS *VendorClass;
  56. } HTTP_BOOT_DHCP6_OPTION_ENTRY;
  57. #define HTTP_CACHED_DHCP6_PACKET_MAX_SIZE (OFFSET_OF (EFI_DHCP6_PACKET, Dhcp6) + HTTP_BOOT_DHCP6_PACKET_MAX_SIZE)
  58. typedef union {
  59. EFI_DHCP6_PACKET Offer;
  60. EFI_DHCP6_PACKET Ack;
  61. UINT8 Buffer[HTTP_CACHED_DHCP6_PACKET_MAX_SIZE];
  62. } HTTP_BOOT_DHCP6_PACKET;
  63. typedef struct {
  64. HTTP_BOOT_DHCP6_PACKET Packet;
  65. HTTP_BOOT_OFFER_TYPE OfferType;
  66. EFI_DHCP6_PACKET_OPTION *OptList[HTTP_BOOT_DHCP6_IDX_MAX];
  67. VOID *UriParser;
  68. } HTTP_BOOT_DHCP6_PACKET_CACHE;
  69. #define GET_NEXT_DHCP6_OPTION(Opt) \
  70. (EFI_DHCP6_PACKET_OPTION *) ((UINT8 *) (Opt) + \
  71. sizeof (EFI_DHCP6_PACKET_OPTION) + (NTOHS ((Opt)->OpLen)) - 1)
  72. #define GET_DHCP6_OPTION_SIZE(Pkt) \
  73. ((Pkt)->Length - sizeof (EFI_DHCP6_HEADER))
  74. /**
  75. Start the S.A.R.R DHCPv6 process to acquire the IPv6 address and other Http boot information.
  76. @param[in] Private Pointer to HTTP_BOOT private data.
  77. @retval EFI_SUCCESS The S.A.R.R process successfully finished.
  78. @retval Others Failed to finish the S.A.R.R process.
  79. **/
  80. EFI_STATUS
  81. HttpBootDhcp6Sarr (
  82. IN HTTP_BOOT_PRIVATE_DATA *Private
  83. );
  84. /**
  85. Set the IP6 policy to Automatic.
  86. @param[in] Private The pointer to HTTP_BOOT_PRIVATE_DATA.
  87. @retval EFI_SUCCESS Switch the IP policy succesfully.
  88. @retval Others Unexpect error happened.
  89. **/
  90. EFI_STATUS
  91. HttpBootSetIp6Policy (
  92. IN HTTP_BOOT_PRIVATE_DATA *Private
  93. );
  94. /**
  95. This function will register the default DNS addresses to the network device.
  96. @param[in] Private The pointer to HTTP_BOOT_PRIVATE_DATA.
  97. @param[in] DataLength Size of the buffer pointed to by DnsServerData in bytes.
  98. @param[in] DnsServerData Point a list of DNS server address in an array
  99. of EFI_IPv6_ADDRESS instances.
  100. @retval EFI_SUCCESS The DNS configuration has been configured successfully.
  101. @retval Others Failed to configure the address.
  102. **/
  103. EFI_STATUS
  104. HttpBootSetIp6Dns (
  105. IN HTTP_BOOT_PRIVATE_DATA *Private,
  106. IN UINTN DataLength,
  107. IN VOID *DnsServerData
  108. );
  109. /**
  110. This function will register the IPv6 gateway address to the network device.
  111. @param[in] Private The pointer to HTTP_BOOT_PRIVATE_DATA.
  112. @retval EFI_SUCCESS The new IP configuration has been configured successfully.
  113. @retval Others Failed to configure the address.
  114. **/
  115. EFI_STATUS
  116. HttpBootSetIp6Gateway (
  117. IN HTTP_BOOT_PRIVATE_DATA *Private
  118. );
  119. /**
  120. This function will register the station IP address.
  121. @param[in] Private The pointer to HTTP_BOOT_PRIVATE_DATA.
  122. @retval EFI_SUCCESS The new IP address has been configured successfully.
  123. @retval Others Failed to configure the address.
  124. **/
  125. EFI_STATUS
  126. HttpBootSetIp6Address (
  127. IN HTTP_BOOT_PRIVATE_DATA *Private
  128. );
  129. #endif