]> git.proxmox.com Git - mirror_edk2.git/blob - NetworkPkg/DnsDxe/DnsDhcp.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[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 #define DHCP6_TAG_DNS_REQUEST 6
31 #define DHCP6_TAG_DNS_SERVER 23
32
33 #define DNS_CHECK_MEDIA_GET_DHCP_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(20)
34
35 //
36 // The required Dns4 server information.
37 //
38 typedef struct {
39 UINT32 *ServerCount;
40 EFI_IPv4_ADDRESS *ServerList;
41 } DNS4_SERVER_INFOR;
42
43 //
44 // The required Dns6 server information.
45 //
46 typedef struct {
47 UINT32 *ServerCount;
48 EFI_IPv6_ADDRESS *ServerList;
49 } DNS6_SERVER_INFOR;
50
51 #pragma pack()
52
53 /**
54 Parse the ACK to get required information
55
56 @param Dhcp4 The DHCP4 protocol.
57 @param Packet Packet waiting for parse.
58 @param DnsServerInfor The required Dns4 server information.
59
60 @retval EFI_SUCCESS The DNS information is got from the DHCP ACK.
61 @retval EFI_NO_MAPPING DHCP failed to acquire address and other information.
62 @retval EFI_DEVICE_ERROR Other errors as indicated.
63 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
64
65 **/
66 EFI_STATUS
67 ParseDhcp4Ack (
68 IN EFI_DHCP4_PROTOCOL *Dhcp4,
69 IN EFI_DHCP4_PACKET *Packet,
70 IN DNS4_SERVER_INFOR *DnsServerInfor
71 );
72
73 /**
74 EFI_DHCP6_INFO_CALLBACK is provided by the consumer of the EFI DHCPv6 Protocol
75 instance to intercept events that occurs in the DHCPv6 Information Request
76 exchange process.
77
78 @param This Pointer to the EFI_DHCP6_PROTOCOL instance that
79 is used to configure this callback function.
80 @param Context Pointer to the context that is initialized in
81 the EFI_DHCP6_PROTOCOL.InfoRequest().
82 @param Packet Pointer to Reply packet that has been received.
83 The EFI DHCPv6 Protocol instance is responsible
84 for freeing the buffer.
85
86 @retval EFI_SUCCESS The DNS information is got from the DHCP ACK.
87 @retval EFI_DEVICE_ERROR Other errors as indicated.
88 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
89 **/
90 EFI_STATUS
91 EFIAPI
92 ParseDhcp6Ack (
93 IN EFI_DHCP6_PROTOCOL *This,
94 IN VOID *Context,
95 IN EFI_DHCP6_PACKET *Packet
96 );
97
98 /**
99 Parse the DHCP ACK to get Dns4 server information.
100
101 @param Instance The DNS instance.
102 @param DnsServerCount Retrieved Dns4 server Ip count.
103 @param DnsServerList Retrieved Dns4 server Ip list.
104
105 @retval EFI_SUCCESS The Dns4 information is got from the DHCP ACK.
106 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
107 @retval EFI_NO_MEDIA There was a media error.
108 @retval Others Other errors as indicated.
109
110 **/
111 EFI_STATUS
112 GetDns4ServerFromDhcp4 (
113 IN DNS_INSTANCE *Instance,
114 OUT UINT32 *DnsServerCount,
115 OUT EFI_IPv4_ADDRESS **DnsServerList
116 );
117
118 /**
119 Parse the DHCP ACK to get Dns6 server information.
120
121 @param Image The handle of the driver image.
122 @param Controller The handle of the controller.
123 @param DnsServerCount Retrieved Dns6 server Ip count.
124 @param DnsServerList Retrieved Dns6 server Ip list.
125
126 @retval EFI_SUCCESS The Dns6 information is got from the DHCP ACK.
127 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
128 @retval EFI_NO_MEDIA There was a media error.
129 @retval Others Other errors as indicated.
130
131 **/
132 EFI_STATUS
133 GetDns6ServerFromDhcp6 (
134 IN EFI_HANDLE Image,
135 IN EFI_HANDLE Controller,
136 OUT UINT32 *DnsServerCount,
137 OUT EFI_IPv6_ADDRESS **DnsServerList
138 );
139
140 #endif