Ip6ConfigImpl.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. /** @file
  2. Definitions for EFI IPv6 Configuration Protocol implementation.
  3. Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef __IP6_CONFIG_IMPL_H__
  7. #define __IP6_CONFIG_IMPL_H__
  8. #define IP6_CONFIG_INSTANCE_SIGNATURE SIGNATURE_32 ('I', 'P', '6', 'C')
  9. #define IP6_FORM_CALLBACK_INFO_SIGNATURE SIGNATURE_32 ('I', 'F', 'C', 'I')
  10. #define IP6_CONFIG_VARIABLE_ATTRIBUTE (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS)
  11. #define IP6_CONFIG_DEFAULT_DAD_XMITS 1
  12. #define DATA_ATTRIB_SIZE_FIXED 0x1
  13. #define DATA_ATTRIB_VOLATILE 0x2
  14. #define DATA_ATTRIB_SET(Attrib, Bits) (BOOLEAN)((Attrib) & (Bits))
  15. #define SET_DATA_ATTRIB(Attrib, Bits) ((Attrib) |= (Bits))
  16. typedef struct _IP6_CONFIG_INSTANCE IP6_CONFIG_INSTANCE;
  17. #define IP6_CONFIG_INSTANCE_FROM_PROTOCOL(Proto) \
  18. CR ((Proto), \
  19. IP6_CONFIG_INSTANCE, \
  20. Ip6Config, \
  21. IP6_CONFIG_INSTANCE_SIGNATURE \
  22. )
  23. #define IP6_CONFIG_INSTANCE_FROM_FORM_CALLBACK(Callback) \
  24. CR ((Callback), \
  25. IP6_CONFIG_INSTANCE, \
  26. CallbackInfo, \
  27. IP6_CONFIG_INSTANCE_SIGNATURE \
  28. )
  29. #define IP6_SERVICE_FROM_IP6_CONFIG_INSTANCE(Instance) \
  30. CR ((Instance), \
  31. IP6_SERVICE, \
  32. Ip6ConfigInstance, \
  33. IP6_SERVICE_SIGNATURE \
  34. )
  35. #define IP6_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS(ConfigAccess) \
  36. CR ((ConfigAccess), \
  37. IP6_FORM_CALLBACK_INFO, \
  38. HiiConfigAccess, \
  39. IP6_FORM_CALLBACK_INFO_SIGNATURE \
  40. )
  41. /**
  42. The prototype of work function for EfiIp6ConfigSetData().
  43. @param[in] Instance The pointer to the IP6 config instance data.
  44. @param[in] DataSize In bytes, the size of the buffer pointed to by Data.
  45. @param[in] Data The data buffer to set.
  46. @retval EFI_BAD_BUFFER_SIZE The DataSize does not match the size of the type,
  47. 8 bytes.
  48. @retval EFI_SUCCESS The specified configuration data for the EFI IPv6
  49. network stack was set successfully.
  50. **/
  51. typedef
  52. EFI_STATUS
  53. (*IP6_CONFIG_SET_DATA) (
  54. IN IP6_CONFIG_INSTANCE *Instance,
  55. IN UINTN DataSize,
  56. IN VOID *Data
  57. );
  58. /**
  59. The prototype of work function for EfiIp6ConfigGetData().
  60. @param[in] Instance The pointer to the IP6 config instance data.
  61. @param[in, out] DataSize On input, in bytes, the size of Data. On output, in
  62. bytes, the size of buffer required to store the specified
  63. configuration data.
  64. @param[in] Data The data buffer in which the configuration data is returned.
  65. Ignored if DataSize is ZERO.
  66. @retval EFI_BUFFER_TOO_SMALL The size of Data is too small for the specified
  67. configuration data, and the required size is
  68. returned in DataSize.
  69. @retval EFI_SUCCESS The specified configuration data was obtained successfully.
  70. **/
  71. typedef
  72. EFI_STATUS
  73. (*IP6_CONFIG_GET_DATA) (
  74. IN IP6_CONFIG_INSTANCE *Instance,
  75. IN OUT UINTN *DataSize,
  76. IN VOID *Data OPTIONAL
  77. );
  78. typedef union {
  79. VOID *Ptr;
  80. EFI_IP6_CONFIG_INTERFACE_INFO *IfInfo;
  81. EFI_IP6_CONFIG_INTERFACE_ID *AltIfId;
  82. EFI_IP6_CONFIG_POLICY *Policy;
  83. EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS *DadXmits;
  84. EFI_IP6_CONFIG_MANUAL_ADDRESS *ManualAddress;
  85. EFI_IPv6_ADDRESS *Gateway;
  86. EFI_IPv6_ADDRESS *DnsServers;
  87. } IP6_CONFIG_DATA;
  88. typedef struct {
  89. IP6_CONFIG_SET_DATA SetData;
  90. IP6_CONFIG_GET_DATA GetData;
  91. EFI_STATUS Status;
  92. UINT8 Attribute;
  93. NET_MAP EventMap;
  94. IP6_CONFIG_DATA Data;
  95. UINTN DataSize;
  96. } IP6_CONFIG_DATA_ITEM;
  97. typedef struct {
  98. UINT16 Offset;
  99. UINT32 DataSize;
  100. EFI_IP6_CONFIG_DATA_TYPE DataType;
  101. } IP6_CONFIG_DATA_RECORD;
  102. #pragma pack(1)
  103. //
  104. // heap data that contains the data for each data record.
  105. //
  106. // BOOLEAN IsAltIfIdSet;
  107. // EFI_IP6_CONFIG_POLICY Policy;
  108. // EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS DadXmits;
  109. // UINT32 ManualaddressCount;
  110. // UINT32 GatewayCount;
  111. // UINT32 DnsServersCount;
  112. // EFI_IP6_CONFIG_INTERFACE_ID AltIfId;
  113. // EFI_IP6_CONFIG_MANUAL_ADDRESS ManualAddress[];
  114. // EFI_IPv6_ADDRESS Gateway[];
  115. // EFI_IPv6_ADDRESS DnsServers[];
  116. //
  117. typedef struct {
  118. UINT32 IaId;
  119. UINT16 Checksum;
  120. UINT16 DataRecordCount;
  121. IP6_CONFIG_DATA_RECORD DataRecord[1];
  122. } IP6_CONFIG_VARIABLE;
  123. #pragma pack()
  124. typedef struct {
  125. LIST_ENTRY Link;
  126. EFI_IP6_ADDRESS_INFO AddrInfo;
  127. } IP6_ADDRESS_INFO_ENTRY;
  128. typedef struct {
  129. EFI_IP6_CONFIG_POLICY Policy; ///< manual or automatic
  130. EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS DadTransmitCount; ///< dad transmits count
  131. EFI_IP6_CONFIG_INTERFACE_ID InterfaceId; ///< alternative interface id
  132. LIST_ENTRY ManualAddress; ///< IP addresses
  133. UINT32 ManualAddressCount; ///< IP addresses count
  134. LIST_ENTRY GatewayAddress; ///< Gateway address
  135. UINT32 GatewayAddressCount; ///< Gateway address count
  136. LIST_ENTRY DnsAddress; ///< DNS server address
  137. UINT32 DnsAddressCount; ///< DNS server address count
  138. } IP6_CONFIG_NVDATA;
  139. typedef struct _IP6_FORM_CALLBACK_INFO {
  140. UINT32 Signature;
  141. EFI_HANDLE ChildHandle;
  142. EFI_HII_CONFIG_ACCESS_PROTOCOL HiiConfigAccess;
  143. EFI_DEVICE_PATH_PROTOCOL *HiiVendorDevicePath;
  144. EFI_HII_HANDLE RegisteredHandle;
  145. } IP6_FORM_CALLBACK_INFO;
  146. struct _IP6_CONFIG_INSTANCE {
  147. UINT32 Signature;
  148. BOOLEAN Configured;
  149. LIST_ENTRY Link;
  150. UINT16 IfIndex;
  151. EFI_IP6_CONFIG_INTERFACE_INFO InterfaceInfo;
  152. EFI_IP6_CONFIG_INTERFACE_ID AltIfId;
  153. EFI_IP6_CONFIG_POLICY Policy;
  154. EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS DadXmits;
  155. IP6_CONFIG_DATA_ITEM DataItem[Ip6ConfigDataTypeMaximum];
  156. NET_MAP DadFailedMap;
  157. NET_MAP DadPassedMap;
  158. EFI_IP6_CONFIG_PROTOCOL Ip6Config;
  159. EFI_EVENT Dhcp6SbNotifyEvent;
  160. VOID *Registration;
  161. EFI_HANDLE Dhcp6Handle;
  162. EFI_DHCP6_PROTOCOL *Dhcp6;
  163. BOOLEAN OtherInfoOnly;
  164. UINT32 IaId;
  165. EFI_EVENT Dhcp6Event;
  166. UINT32 FailedIaAddressCount;
  167. EFI_IPv6_ADDRESS *DeclineAddress;
  168. UINT32 DeclineAddressCount;
  169. IP6_FORM_CALLBACK_INFO CallbackInfo;
  170. IP6_CONFIG_NVDATA Ip6NvData;
  171. };
  172. /**
  173. Read the configuration data from variable storage according to the VarName and
  174. gEfiIp6ConfigProtocolGuid. It checks the integrity of variable data. If the
  175. data is corrupted, it clears the variable data to ZERO. Otherwise, it outputs the
  176. configuration data to IP6_CONFIG_INSTANCE.
  177. @param[in] VarName The pointer to the variable name
  178. @param[in, out] Instance The pointer to the IP6 config instance data.
  179. @retval EFI_NOT_FOUND The variable can not be found or already corrupted.
  180. @retval EFI_OUT_OF_RESOURCES Fail to allocate resource to complete the operation.
  181. @retval EFI_SUCCESS The configuration data was retrieved successfully.
  182. **/
  183. EFI_STATUS
  184. Ip6ConfigReadConfigData (
  185. IN CHAR16 *VarName,
  186. IN OUT IP6_CONFIG_INSTANCE *Instance
  187. );
  188. /**
  189. The event process routine when the DHCPv6 server is answered with a reply packet
  190. for an information request.
  191. @param[in] This Points to the EFI_DHCP6_PROTOCOL.
  192. @param[in] Context The pointer to the IP6 configuration instance data.
  193. @param[in] Packet The DHCPv6 reply packet.
  194. @retval EFI_SUCCESS The DNS server address was retrieved from the reply packet.
  195. @retval EFI_NOT_READY The reply packet does not contain the DNS server option, or
  196. the DNS server address is not valid.
  197. **/
  198. EFI_STATUS
  199. EFIAPI
  200. Ip6ConfigOnDhcp6Reply (
  201. IN EFI_DHCP6_PROTOCOL *This,
  202. IN VOID *Context,
  203. IN EFI_DHCP6_PACKET *Packet
  204. );
  205. /**
  206. The work function to trigger the DHCPv6 process to perform a stateful autoconfiguration.
  207. @param[in] Instance Pointer to the IP6 config instance data.
  208. @param[in] OtherInfoOnly If FALSE, get stateful address and other information
  209. via DHCPv6. Otherwise, only get the other information.
  210. @retval EFI_SUCCESS The operation finished successfully.
  211. @retval EFI_UNSUPPORTED The DHCP6 driver is not available.
  212. **/
  213. EFI_STATUS
  214. Ip6ConfigStartStatefulAutoConfig (
  215. IN IP6_CONFIG_INSTANCE *Instance,
  216. IN BOOLEAN OtherInfoOnly
  217. );
  218. /**
  219. Initialize an IP6_CONFIG_INSTANCE.
  220. @param[out] Instance The buffer of IP6_CONFIG_INSTANCE to be initialized.
  221. @retval EFI_OUT_OF_RESOURCES Failed to allocate resources to complete the operation.
  222. @retval EFI_SUCCESS The IP6_CONFIG_INSTANCE initialized successfully.
  223. **/
  224. EFI_STATUS
  225. Ip6ConfigInitInstance (
  226. OUT IP6_CONFIG_INSTANCE *Instance
  227. );
  228. /**
  229. Release an IP6_CONFIG_INSTANCE.
  230. @param[in, out] Instance The buffer of IP6_CONFIG_INSTANCE to be freed.
  231. **/
  232. VOID
  233. Ip6ConfigCleanInstance (
  234. IN OUT IP6_CONFIG_INSTANCE *Instance
  235. );
  236. /**
  237. Destroy the Dhcp6 child in IP6_CONFIG_INSTANCE and release the resources.
  238. @param[in, out] Instance The buffer of IP6_CONFIG_INSTANCE to be freed.
  239. @retval EFI_SUCCESS The child was successfully destroyed.
  240. @retval Others Failed to destroy the child.
  241. **/
  242. EFI_STATUS
  243. Ip6ConfigDestroyDhcp6 (
  244. IN OUT IP6_CONFIG_INSTANCE *Instance
  245. );
  246. #endif