1 /** @file 2 Functions declaration related with DHCPv6 for HTTP boot driver. 3 4 Copyright (c) 2015, 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 28 #define HTTP_BOOT_DHCP6_OPT_CLIENT_ID 1 29 #define HTTP_BOOT_DHCP6_OPT_SERVER_ID 2 30 #define HTTP_BOOT_DHCP6_OPT_IA_NA 3 31 #define HTTP_BOOT_DHCP6_OPT_IA_TA 4 32 #define HTTP_BOOT_DHCP6_OPT_IAADDR 5 33 #define HTTP_BOOT_DHCP6_OPT_ORO 6 34 #define HTTP_BOOT_DHCP6_OPT_PREFERENCE 7 35 #define HTTP_BOOT_DHCP6_OPT_ELAPSED_TIME 8 36 #define HTTP_BOOT_DHCP6_OPT_REPLAY_MSG 9 37 #define HTTP_BOOT_DHCP6_OPT_AUTH 11 38 #define HTTP_BOOT_DHCP6_OPT_UNICAST 12 39 #define HTTP_BOOT_DHCP6_OPT_STATUS_CODE 13 40 #define HTTP_BOOT_DHCP6_OPT_RAPID_COMMIT 14 41 #define HTTP_BOOT_DHCP6_OPT_USER_CLASS 15 42 #define HTTP_BOOT_DHCP6_OPT_VENDOR_CLASS 16 43 #define HTTP_BOOT_DHCP6_OPT_VENDOR_OPTS 17 44 #define HTTP_BOOT_DHCP6_OPT_INTERFACE_ID 18 45 #define HTTP_BOOT_DHCP6_OPT_RECONFIG_MSG 19 46 #define HTTP_BOOT_DHCP6_OPT_RECONFIG_ACCEPT 20 47 #define HTTP_BOOT_DHCP6_OPT_DNS_SERVERS 23 48 #define HTTP_BOOT_DHCP6_OPT_BOOT_FILE_URL 59 // Assigned by IANA, RFC 5970 49 #define HTTP_BOOT_DHCP6_OPT_BOOT_FILE_PARAM 60 // Assigned by IANA, RFC 5970 50 #define HTTP_BOOT_DHCP6_OPT_ARCH 61 // Assigned by IANA, RFC 5970 51 #define HTTP_BOOT_DHCP6_OPT_UNDI 62 // Assigned by IANA, RFC 5970 52 #define HTTP_BOOT_DHCP6_ENTERPRISE_NUM 343 // TODO: IANA TBD: temporarily using Intel's 53 #define HTTP_BOOT_DHCP6_MAX_BOOT_FILE_SIZE 65535 // It's a limitation of bit length, 65535*512 bytes. 54 55 #define HTTP_BOOT_DHCP6_IDX_IA_NA 0 56 #define HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL 1 57 #define HTTP_BOOT_DHCP6_IDX_BOOT_FILE_PARAM 2 58 #define HTTP_BOOT_DHCP6_IDX_VENDOR_CLASS 3 59 #define HTTP_BOOT_DHCP6_IDX_DNS_SERVER 4 60 #define HTTP_BOOT_DHCP6_IDX_MAX 5 61 62 #pragma pack(1) 63 typedef struct { 64 UINT16 OpCode[256]; 65 } HTTP_BOOT_DHCP6_OPTION_ORO; 66 67 typedef struct { 68 UINT8 Type; 69 UINT8 MajorVer; 70 UINT8 MinorVer; 71 } HTTP_BOOT_DHCP6_OPTION_UNDI; 72 73 typedef struct { 74 UINT16 Type; 75 } HTTP_BOOT_DHCP6_OPTION_ARCH; 76 77 typedef struct { 78 UINT8 ClassIdentifier[10]; 79 UINT8 ArchitecturePrefix[5]; 80 UINT8 ArchitectureType[5]; 81 UINT8 Lit3[1]; 82 UINT8 InterfaceName[4]; 83 UINT8 Lit4[1]; 84 UINT8 UndiMajor[3]; 85 UINT8 UndiMinor[3]; 86 } HTTP_BOOT_CLASS_ID; 87 88 typedef struct { 89 UINT32 Vendor; 90 UINT16 ClassLen; 91 HTTP_BOOT_CLASS_ID ClassId; 92 } HTTP_BOOT_DHCP6_OPTION_VENDOR_CLASS; 93 94 #pragma pack() 95 96 typedef union { 97 HTTP_BOOT_DHCP6_OPTION_ORO *Oro; 98 HTTP_BOOT_DHCP6_OPTION_UNDI *Undi; 99 HTTP_BOOT_DHCP6_OPTION_ARCH *Arch; 100 HTTP_BOOT_DHCP6_OPTION_VENDOR_CLASS *VendorClass; 101 } HTTP_BOOT_DHCP6_OPTION_ENTRY; 102 103 typedef union { 104 EFI_DHCP6_PACKET Offer; 105 EFI_DHCP6_PACKET Ack; 106 UINT8 Buffer[HTTP_BOOT_DHCP6_PACKET_MAX_SIZE]; 107 } HTTP_BOOT_DHCP6_PACKET; 108 109 typedef struct { 110 HTTP_BOOT_DHCP6_PACKET Packet; 111 HTTP_BOOT_OFFER_TYPE OfferType; 112 EFI_DHCP6_PACKET_OPTION *OptList[HTTP_BOOT_DHCP6_IDX_MAX]; 113 VOID *UriParser; 114 } HTTP_BOOT_DHCP6_PACKET_CACHE; 115 116 #define GET_NEXT_DHCP6_OPTION(Opt) \ 117 (EFI_DHCP6_PACKET_OPTION *) ((UINT8 *) (Opt) + \ 118 sizeof (EFI_DHCP6_PACKET_OPTION) + (NTOHS ((Opt)->OpLen)) - 1) 119 120 #define GET_DHCP6_OPTION_SIZE(Pkt) \ 121 ((Pkt)->Length - sizeof (EFI_DHCP6_HEADER)) 122 123 /** 124 Start the S.A.R.R DHCPv6 process to acquire the IPv6 address and other Http boot information. 125 126 @param[in] Private Pointer to HTTP_BOOT private data. 127 128 @retval EFI_SUCCESS The S.A.R.R process successfully finished. 129 @retval Others Failed to finish the S.A.R.R process. 130 131 **/ 132 EFI_STATUS 133 HttpBootDhcp6Sarr ( 134 IN HTTP_BOOT_PRIVATE_DATA *Private 135 ); 136 137 /** 138 Set the IP6 policy to Automatic. 139 140 @param[in] Private The pointer to HTTP_BOOT_PRIVATE_DATA. 141 142 @retval EFI_SUCCESS Switch the IP policy succesfully. 143 @retval Others Unexpect error happened. 144 145 **/ 146 EFI_STATUS 147 HttpBootSetIp6Policy ( 148 IN HTTP_BOOT_PRIVATE_DATA *Private 149 ); 150 151 /** 152 This function will register the default DNS addresses to the network device. 153 154 @param[in] Private The pointer to HTTP_BOOT_PRIVATE_DATA. 155 @param[in] DataLength Size of the buffer pointed to by DnsServerData in bytes. 156 @param[in] DnsServerData Point a list of DNS server address in an array 157 of EFI_IPv6_ADDRESS instances. 158 159 @retval EFI_SUCCESS The DNS configuration has been configured successfully. 160 @retval Others Failed to configure the address. 161 162 **/ 163 EFI_STATUS 164 HttpBootSetIp6Dns ( 165 IN HTTP_BOOT_PRIVATE_DATA *Private, 166 IN UINTN DataLength, 167 IN VOID *DnsServerData 168 ); 169 170 /** 171 This function will register the IPv6 gateway address to the network device. 172 173 @param[in] Private The pointer to HTTP_BOOT_PRIVATE_DATA. 174 175 @retval EFI_SUCCESS The new IP configuration has been configured successfully. 176 @retval Others Failed to configure the address. 177 178 **/ 179 EFI_STATUS 180 HttpBootSetIp6Gateway ( 181 IN HTTP_BOOT_PRIVATE_DATA *Private 182 ); 183 184 /** 185 This function will register the station IP address. 186 187 @param[in] Private The pointer to HTTP_BOOT_PRIVATE_DATA. 188 189 @retval EFI_SUCCESS The new IP address has been configured successfully. 190 @retval Others Failed to configure the address. 191 192 **/ 193 EFI_STATUS 194 HttpBootSetIp6Address ( 195 IN HTTP_BOOT_PRIVATE_DATA *Private 196 ); 197 198 #endif 199