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