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