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