]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.h
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Dhcp4Dxe / Dhcp4Impl.h
... / ...
CommitLineData
1/** @file\r
2 EFI DHCP protocol implementation.\r
3 RFCs supported are:\r
4 RFC 2131: Dynamic Host Configuration Protocol\r
5 RFC 2132: DHCP Options and BOOTP Vendor Extensions\r
6 RFC 1534: Interoperation Between DHCP and BOOTP\r
7 RFC 3396: Encoding Long Options in DHCP.\r
8\r
9Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
10This program and the accompanying materials\r
11are licensed and made available under the terms and conditions of the BSD License\r
12which accompanies this distribution. The full text of the license may be found at\r
13http://opensource.org/licenses/bsd-license.php\r
14\r
15THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
16WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
17\r
18**/\r
19\r
20#ifndef __EFI_DHCP4_IMPL_H__\r
21#define __EFI_DHCP4_IMPL_H__\r
22\r
23\r
24\r
25#include <Uefi.h>\r
26\r
27#include <Protocol/Dhcp4.h>\r
28#include <Protocol/Udp4.h>\r
29#include <IndustryStandard/Dhcp.h>\r
30#include <Library/DebugLib.h>\r
31#include <Library/UefiDriverEntryPoint.h>\r
32#include <Library/UefiBootServicesTableLib.h>\r
33#include <Library/UefiLib.h>\r
34#include <Library/BaseLib.h>\r
35#include <Library/NetLib.h>\r
36\r
37typedef struct _DHCP_SERVICE DHCP_SERVICE;\r
38typedef struct _DHCP_PROTOCOL DHCP_PROTOCOL;\r
39\r
40#include "Dhcp4Option.h"\r
41#include "Dhcp4Io.h"\r
42\r
43#define DHCP_SERVICE_SIGNATURE SIGNATURE_32 ('D', 'H', 'C', 'P')\r
44#define DHCP_PROTOCOL_SIGNATURE SIGNATURE_32 ('d', 'h', 'c', 'p')\r
45\r
46#define DHCP_CHECK_MEDIA_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(20)\r
47\r
48//\r
49// The state of the DHCP service. It starts as UNCONFIGED. If\r
50// and active child configures the service successfully, it\r
51// goes to CONFIGED. If the active child configures NULL, it\r
52// goes back to UNCONFIGED. It becomes DESTROY if it is (partly)\r
53// destroyed.\r
54//\r
55#define DHCP_UNCONFIGED 0\r
56#define DHCP_CONFIGED 1\r
57#define DHCP_DESTROY 2\r
58\r
59\r
60struct _DHCP_PROTOCOL {\r
61 UINT32 Signature;\r
62 EFI_DHCP4_PROTOCOL Dhcp4Protocol;\r
63 LIST_ENTRY Link;\r
64 EFI_HANDLE Handle;\r
65 DHCP_SERVICE *Service;\r
66\r
67 BOOLEAN InDestroy;\r
68\r
69 EFI_EVENT CompletionEvent;\r
70 EFI_EVENT RenewRebindEvent;\r
71\r
72 EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN *Token;\r
73 UDP_IO *UdpIo; // The UDP IO used for TransmitReceive.\r
74 UINT32 Timeout;\r
75 UINT16 ElaspedTime;\r
76 NET_BUF_QUEUE ResponseQueue;\r
77};\r
78\r
79//\r
80// DHCP driver is specical in that it is a singleton. Although it\r
81// has a service binding, there can be only one active child.\r
82//\r
83struct _DHCP_SERVICE {\r
84 UINT32 Signature;\r
85 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;\r
86\r
87 INTN ServiceState; // CONFIGED, UNCONFIGED, and DESTROY\r
88\r
89 EFI_HANDLE Controller;\r
90 EFI_HANDLE Image;\r
91\r
92 LIST_ENTRY Children;\r
93 UINTN NumChildren;\r
94\r
95 INTN DhcpState;\r
96 EFI_STATUS IoStatus; // the result of last user operation\r
97 UINT32 Xid;\r
98\r
99 IP4_ADDR ClientAddr; // lease IP or configured client address\r
100 IP4_ADDR Netmask;\r
101 IP4_ADDR ServerAddr;\r
102\r
103 EFI_DHCP4_PACKET *LastOffer; // The last received offer\r
104 EFI_DHCP4_PACKET *Selected;\r
105 DHCP_PARAMETER *Para;\r
106\r
107 UINT32 Lease;\r
108 UINT32 T1;\r
109 UINT32 T2;\r
110 INTN ExtraRefresh; // This refresh is reqested by user\r
111\r
112 UDP_IO *UdpIo; // Udp child receiving all DHCP message\r
113 UDP_IO *LeaseIoPort; // Udp child with lease IP\r
114 EFI_DHCP4_PACKET *LastPacket; // The last sent packet for retransmission\r
115 EFI_MAC_ADDRESS Mac;\r
116 UINT8 HwType;\r
117 UINT8 HwLen;\r
118 UINT8 ClientAddressSendOut[16];\r
119\r
120 DHCP_PROTOCOL *ActiveChild;\r
121 EFI_DHCP4_CONFIG_DATA ActiveConfig;\r
122 UINT32 UserOptionLen;\r
123\r
124 //\r
125 // Timer event and various timer\r
126 //\r
127 EFI_EVENT Timer;\r
128\r
129 UINT32 PacketToLive; // Retransmission timer for our packets\r
130 UINT32 LastTimeout; // Record the init value of PacketToLive every time\r
131 INTN CurRetry;\r
132 INTN MaxRetries;\r
133 UINT32 LeaseLife;\r
134};\r
135\r
136typedef struct {\r
137 EFI_DHCP4_PACKET_OPTION **Option;\r
138 UINT32 OptionCount;\r
139 UINT32 Index;\r
140} DHCP_PARSE_CONTEXT;\r
141\r
142#define DHCP_INSTANCE_FROM_THIS(Proto) \\r
143 CR ((Proto), DHCP_PROTOCOL, Dhcp4Protocol, DHCP_PROTOCOL_SIGNATURE)\r
144\r
145#define DHCP_SERVICE_FROM_THIS(Sb) \\r
146 CR ((Sb), DHCP_SERVICE, ServiceBinding, DHCP_SERVICE_SIGNATURE)\r
147\r
148extern EFI_DHCP4_PROTOCOL mDhcp4ProtocolTemplate;\r
149\r
150/**\r
151 Give up the control of the DHCP service to let other child\r
152 resume. Don't change the service's DHCP state and the Client\r
153 address and option list configure as required by RFC2131.\r
154\r
155 @param DhcpSb The DHCP service instance.\r
156\r
157**/\r
158VOID\r
159DhcpYieldControl (\r
160 IN DHCP_SERVICE *DhcpSb\r
161 );\r
162\r
163/**\r
164 Complete a Dhcp4 transaction and signal the upper layer.\r
165\r
166 @param Instance Dhcp4 instance.\r
167\r
168**/\r
169VOID\r
170PxeDhcpDone (\r
171 IN DHCP_PROTOCOL *Instance\r
172 );\r
173\r
174/**\r
175 Free the resource related to the configure parameters.\r
176 DHCP driver will make a copy of the user's configure\r
177 such as the time out value.\r
178\r
179 @param Config The DHCP configure data\r
180\r
181**/\r
182VOID\r
183DhcpCleanConfigure (\r
184 IN OUT EFI_DHCP4_CONFIG_DATA *Config\r
185 );\r
186\r
187/**\r
188 Callback of Dhcp packet. Does nothing.\r
189\r
190 @param Arg The context.\r
191\r
192**/\r
193VOID\r
194EFIAPI\r
195DhcpDummyExtFree (\r
196 IN VOID *Arg\r
197 );\r
198\r
199/**\r
200 Set the elapsed time based on the given instance and the pointer to the\r
201 elapsed time option.\r
202\r
203 @param[in] Elapsed The pointer to the position to append.\r
204 @param[in] Instance The pointer to the Dhcp4 instance.\r
205**/\r
206VOID\r
207SetElapsedTime (\r
208 IN UINT16 *Elapsed,\r
209 IN DHCP_PROTOCOL *Instance\r
210 );\r
211\r
212#endif\r