DnsDhcp.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /** @file
  2. Functions implementation related with DHCPv4/v6 for DNS driver.
  3. Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef _DNS_DHCP_H_
  7. #define _DNS_DHCP_H_
  8. //
  9. // DHCP DNS related
  10. //
  11. #pragma pack(1)
  12. #define IP4_ETHER_PROTO 0x0800
  13. #define DHCP4_OPCODE_REQUEST 1
  14. #define DHCP4_MAGIC 0x63538263 /// network byte order
  15. #define DHCP4_TAG_EOP 255 /// End Option
  16. #define DHCP4_TAG_TYPE 53
  17. #define DHCP4_MSG_REQUEST 3
  18. #define DHCP4_MSG_INFORM 8
  19. #define DHCP4_TAG_PARA_LIST 55
  20. #define DHCP4_TAG_DNS_SERVER 6
  21. #define DHCP6_TAG_DNS_REQUEST 6
  22. #define DHCP6_TAG_DNS_SERVER 23
  23. #define DNS_CHECK_MEDIA_GET_DHCP_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(20)
  24. //
  25. // The required Dns4 server information.
  26. //
  27. typedef struct {
  28. UINT32 *ServerCount;
  29. EFI_IPv4_ADDRESS *ServerList;
  30. } DNS4_SERVER_INFOR;
  31. //
  32. // The required Dns6 server information.
  33. //
  34. typedef struct {
  35. UINT32 *ServerCount;
  36. EFI_IPv6_ADDRESS *ServerList;
  37. } DNS6_SERVER_INFOR;
  38. #pragma pack()
  39. /**
  40. Parse the ACK to get required information
  41. @param Dhcp4 The DHCP4 protocol.
  42. @param Packet Packet waiting for parse.
  43. @param DnsServerInfor The required Dns4 server information.
  44. @retval EFI_SUCCESS The DNS information is got from the DHCP ACK.
  45. @retval EFI_NO_MAPPING DHCP failed to acquire address and other information.
  46. @retval EFI_DEVICE_ERROR Other errors as indicated.
  47. @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
  48. **/
  49. EFI_STATUS
  50. ParseDhcp4Ack (
  51. IN EFI_DHCP4_PROTOCOL *Dhcp4,
  52. IN EFI_DHCP4_PACKET *Packet,
  53. IN DNS4_SERVER_INFOR *DnsServerInfor
  54. );
  55. /**
  56. EFI_DHCP6_INFO_CALLBACK is provided by the consumer of the EFI DHCPv6 Protocol
  57. instance to intercept events that occurs in the DHCPv6 Information Request
  58. exchange process.
  59. @param This Pointer to the EFI_DHCP6_PROTOCOL instance that
  60. is used to configure this callback function.
  61. @param Context Pointer to the context that is initialized in
  62. the EFI_DHCP6_PROTOCOL.InfoRequest().
  63. @param Packet Pointer to Reply packet that has been received.
  64. The EFI DHCPv6 Protocol instance is responsible
  65. for freeing the buffer.
  66. @retval EFI_SUCCESS The DNS information is got from the DHCP ACK.
  67. @retval EFI_DEVICE_ERROR Other errors as indicated.
  68. @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
  69. **/
  70. EFI_STATUS
  71. EFIAPI
  72. ParseDhcp6Ack (
  73. IN EFI_DHCP6_PROTOCOL *This,
  74. IN VOID *Context,
  75. IN EFI_DHCP6_PACKET *Packet
  76. );
  77. /**
  78. Parse the DHCP ACK to get Dns4 server information.
  79. @param Instance The DNS instance.
  80. @param DnsServerCount Retrieved Dns4 server Ip count.
  81. @param DnsServerList Retrieved Dns4 server Ip list.
  82. @retval EFI_SUCCESS The Dns4 information is got from the DHCP ACK.
  83. @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
  84. @retval EFI_NO_MEDIA There was a media error.
  85. @retval Others Other errors as indicated.
  86. **/
  87. EFI_STATUS
  88. GetDns4ServerFromDhcp4 (
  89. IN DNS_INSTANCE *Instance,
  90. OUT UINT32 *DnsServerCount,
  91. OUT EFI_IPv4_ADDRESS **DnsServerList
  92. );
  93. /**
  94. Parse the DHCP ACK to get Dns6 server information.
  95. @param Image The handle of the driver image.
  96. @param Controller The handle of the controller.
  97. @param DnsServerCount Retrieved Dns6 server Ip count.
  98. @param DnsServerList Retrieved Dns6 server Ip list.
  99. @retval EFI_SUCCESS The Dns6 information is got from the DHCP ACK.
  100. @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
  101. @retval EFI_NO_MEDIA There was a media error.
  102. @retval Others Other errors as indicated.
  103. **/
  104. EFI_STATUS
  105. GetDns6ServerFromDhcp6 (
  106. IN EFI_HANDLE Image,
  107. IN EFI_HANDLE Controller,
  108. OUT UINT32 *DnsServerCount,
  109. OUT EFI_IPv6_ADDRESS **DnsServerList
  110. );
  111. #endif