1 /** @file 2 Functions declaration related with DHCPv6 for HTTP boot driver. 3 4 Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR> 5 This program and the accompanying materials are licensed and made available under 6 the terms and conditions of the BSD License that accompanies this distribution. 7 The full text of the license may be found at 8 http://opensource.org/licenses/bsd-license.php. 9 10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 12 13 **/ 14 15 16 #ifndef __EFI_HTTP_BOOT_DHCP6_H__ 17 #define __EFI_HTTP_BOOT_DHCP6_H__ 18 19 #define HTTP_BOOT_OFFER_MAX_NUM 16 20 #define HTTP_BOOT_DHCP6_OPTION_MAX_NUM 16 21 #define HTTP_BOOT_DHCP6_OPTION_MAX_SIZE 312 22 #define HTTP_BOOT_DHCP6_PACKET_MAX_SIZE 1472 23 #define HTTP_BOOT_IP6_ROUTE_TABLE_TIMEOUT 10 24 #define HTTP_BOOT_DEFAULT_HOPLIMIT 64 25 #define HTTP_BOOT_DEFAULT_LIFETIME 50000 26 27 #define HTTP_BOOT_DHCP6_ENTERPRISE_NUM 343 // TODO: IANA TBD: temporarily using Intel's 28 #define HTTP_BOOT_DHCP6_MAX_BOOT_FILE_SIZE 65535 // It's a limitation of bit length, 65535*512 bytes. 29 30 #define HTTP_BOOT_DHCP6_IDX_IA_NA 0 31 #define HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL 1 32 #define HTTP_BOOT_DHCP6_IDX_BOOT_FILE_PARAM 2 33 #define HTTP_BOOT_DHCP6_IDX_VENDOR_CLASS 3 34 #define HTTP_BOOT_DHCP6_IDX_DNS_SERVER 4 35 #define HTTP_BOOT_DHCP6_IDX_MAX 5 36 37 #pragma pack(1) 38 typedef struct { 39 UINT16 OpCode[256]; 40 } HTTP_BOOT_DHCP6_OPTION_ORO; 41 42 typedef struct { 43 UINT8 Type; 44 UINT8 MajorVer; 45 UINT8 MinorVer; 46 } HTTP_BOOT_DHCP6_OPTION_UNDI; 47 48 typedef struct { 49 UINT16 Type; 50 } HTTP_BOOT_DHCP6_OPTION_ARCH; 51 52 typedef struct { 53 UINT8 ClassIdentifier[11]; 54 UINT8 ArchitecturePrefix[5]; 55 UINT8 ArchitectureType[5]; 56 UINT8 Lit3[1]; 57 UINT8 InterfaceName[4]; 58 UINT8 Lit4[1]; 59 UINT8 UndiMajor[3]; 60 UINT8 UndiMinor[3]; 61 } HTTP_BOOT_CLASS_ID; 62 63 typedef struct { 64 UINT32 Vendor; 65 UINT16 ClassLen; 66 HTTP_BOOT_CLASS_ID ClassId; 67 } HTTP_BOOT_DHCP6_OPTION_VENDOR_CLASS; 68 69 #pragma pack() 70 71 typedef union { 72 HTTP_BOOT_DHCP6_OPTION_ORO *Oro; 73 HTTP_BOOT_DHCP6_OPTION_UNDI *Undi; 74 HTTP_BOOT_DHCP6_OPTION_ARCH *Arch; 75 HTTP_BOOT_DHCP6_OPTION_VENDOR_CLASS *VendorClass; 76 } HTTP_BOOT_DHCP6_OPTION_ENTRY; 77 78 #define HTTP_CACHED_DHCP6_PACKET_MAX_SIZE (OFFSET_OF (EFI_DHCP6_PACKET, Dhcp6) + HTTP_BOOT_DHCP6_PACKET_MAX_SIZE) 79 80 typedef union { 81 EFI_DHCP6_PACKET Offer; 82 EFI_DHCP6_PACKET Ack; 83 UINT8 Buffer[HTTP_CACHED_DHCP6_PACKET_MAX_SIZE]; 84 } HTTP_BOOT_DHCP6_PACKET; 85 86 typedef struct { 87 HTTP_BOOT_DHCP6_PACKET Packet; 88 HTTP_BOOT_OFFER_TYPE OfferType; 89 EFI_DHCP6_PACKET_OPTION *OptList[HTTP_BOOT_DHCP6_IDX_MAX]; 90 VOID *UriParser; 91 } HTTP_BOOT_DHCP6_PACKET_CACHE; 92 93 #define GET_NEXT_DHCP6_OPTION(Opt) \ 94 (EFI_DHCP6_PACKET_OPTION *) ((UINT8 *) (Opt) + \ 95 sizeof (EFI_DHCP6_PACKET_OPTION) + (NTOHS ((Opt)->OpLen)) - 1) 96 97 #define GET_DHCP6_OPTION_SIZE(Pkt) \ 98 ((Pkt)->Length - sizeof (EFI_DHCP6_HEADER)) 99 100 /** 101 Start the S.A.R.R DHCPv6 process to acquire the IPv6 address and other Http boot information. 102 103 @param[in] Private Pointer to HTTP_BOOT private data. 104 105 @retval EFI_SUCCESS The S.A.R.R process successfully finished. 106 @retval Others Failed to finish the S.A.R.R process. 107 108 **/ 109 EFI_STATUS 110 HttpBootDhcp6Sarr ( 111 IN HTTP_BOOT_PRIVATE_DATA *Private 112 ); 113 114 /** 115 Set the IP6 policy to Automatic. 116 117 @param[in] Private The pointer to HTTP_BOOT_PRIVATE_DATA. 118 119 @retval EFI_SUCCESS Switch the IP policy succesfully. 120 @retval Others Unexpect error happened. 121 122 **/ 123 EFI_STATUS 124 HttpBootSetIp6Policy ( 125 IN HTTP_BOOT_PRIVATE_DATA *Private 126 ); 127 128 /** 129 This function will register the default DNS addresses to the network device. 130 131 @param[in] Private The pointer to HTTP_BOOT_PRIVATE_DATA. 132 @param[in] DataLength Size of the buffer pointed to by DnsServerData in bytes. 133 @param[in] DnsServerData Point a list of DNS server address in an array 134 of EFI_IPv6_ADDRESS instances. 135 136 @retval EFI_SUCCESS The DNS configuration has been configured successfully. 137 @retval Others Failed to configure the address. 138 139 **/ 140 EFI_STATUS 141 HttpBootSetIp6Dns ( 142 IN HTTP_BOOT_PRIVATE_DATA *Private, 143 IN UINTN DataLength, 144 IN VOID *DnsServerData 145 ); 146 147 /** 148 This function will register the IPv6 gateway address to the network device. 149 150 @param[in] Private The pointer to HTTP_BOOT_PRIVATE_DATA. 151 152 @retval EFI_SUCCESS The new IP configuration has been configured successfully. 153 @retval Others Failed to configure the address. 154 155 **/ 156 EFI_STATUS 157 HttpBootSetIp6Gateway ( 158 IN HTTP_BOOT_PRIVATE_DATA *Private 159 ); 160 161 /** 162 This function will register the station IP address. 163 164 @param[in] Private The pointer to HTTP_BOOT_PRIVATE_DATA. 165 166 @retval EFI_SUCCESS The new IP address has been configured successfully. 167 @retval Others Failed to configure the address. 168 169 **/ 170 EFI_STATUS 171 HttpBootSetIp6Address ( 172 IN HTTP_BOOT_PRIVATE_DATA *Private 173 ); 174 175 #endif 176