]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.h
1. Fix a bug in PXE driver that the PXE boot do not restart if a new boot option...
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Dhcp4Dxe / Dhcp4Impl.h
CommitLineData
83cbd279 1/** @file\r
3e8c18da 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
75dce340 9Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
e5eed7d3 10This program and the accompanying materials\r
83cbd279 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
83cbd279 18**/\r
19\r
20#ifndef __EFI_DHCP4_IMPL_H__\r
21#define __EFI_DHCP4_IMPL_H__\r
22\r
23\r
772db4bb 24\r
2517435c 25#include <Uefi.h>\r
772db4bb 26\r
27#include <Protocol/Dhcp4.h>\r
28#include <Protocol/Udp4.h>\r
29\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
83cbd279 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
f3f2e05d 43#define DHCP_SERVICE_SIGNATURE SIGNATURE_32 ('D', 'H', 'C', 'P')\r
44#define DHCP_PROTOCOL_SIGNATURE SIGNATURE_32 ('d', 'h', 'c', 'p')\r
83cbd279 45\r
f6b7393c 46\r
47//\r
48// The state of the DHCP service. It starts as UNCONFIGED. If\r
49// and active child configures the service successfully, it\r
50// goes to CONFIGED. If the active child configures NULL, it\r
75dce340 51// goes back to UNCONFIGED. It becomes DESTROY if it is (partly)\r
52// destroyed.\r
f6b7393c 53//\r
54#define DHCP_UNCONFIGED 0\r
55#define DHCP_CONFIGED 1\r
75dce340 56#define DHCP_DESTROY 2\r
f6b7393c 57\r
83cbd279 58\r
59struct _DHCP_PROTOCOL {\r
60 UINT32 Signature;\r
61 EFI_DHCP4_PROTOCOL Dhcp4Protocol;\r
e48e37fc 62 LIST_ENTRY Link;\r
83cbd279 63 EFI_HANDLE Handle;\r
64 DHCP_SERVICE *Service;\r
65\r
75dce340 66 BOOLEAN InDestroy;\r
83cbd279 67\r
68 EFI_EVENT CompletionEvent;\r
69 EFI_EVENT RenewRebindEvent;\r
70\r
71 EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN *Token;\r
b45b45b2 72 UDP_IO *UdpIo; // The UDP IO used for TransmitReceive.\r
c4a62a12 73 UINT32 Timeout;\r
842d83d6 74 UINT16 ElaspedTime;\r
c4a62a12 75 NET_BUF_QUEUE ResponseQueue;\r
83cbd279 76};\r
77\r
78//\r
79// DHCP driver is specical in that it is a singleton. Although it\r
80// has a service binding, there can be only one active child.\r
81//\r
82struct _DHCP_SERVICE {\r
83 UINT32 Signature;\r
84 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;\r
85\r
75dce340 86 INTN ServiceState; // CONFIGED, UNCONFIGED, and DESTROY\r
87 BOOLEAN InDestroy;\r
83cbd279 88\r
89 EFI_HANDLE Controller;\r
90 EFI_HANDLE Image;\r
91\r
e48e37fc 92 LIST_ENTRY Children;\r
83cbd279 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
b45b45b2 112 UDP_IO *UdpIo; // Udp child receiving all DHCP message\r
113 UDP_IO *LeaseIoPort; // Udp child with lease IP\r
434ce3fe 114 EFI_DHCP4_PACKET *LastPacket; // The last sent packet for retransmission\r
83cbd279 115 EFI_MAC_ADDRESS Mac;\r
116 UINT8 HwType;\r
117 UINT8 HwLen;\r
982a9eae 118 UINT8 ClientAddressSendOut[16];\r
83cbd279 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
434ce3fe 130 UINT32 LastTimeout; // Record the init value of PacketToLive every time\r
83cbd279 131 INTN CurRetry;\r
132 INTN MaxRetries;\r
83cbd279 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
7bce0c5a 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
7bce0c5a 157**/\r
83cbd279 158VOID\r
159DhcpYieldControl (\r
ed729a0c 160 IN DHCP_SERVICE *DhcpSb\r
83cbd279 161 );\r
162\r
ed729a0c 163/**\r
164 Complete a Dhcp4 transaction and signal the upper layer.\r
235eaa63 165\r
ed729a0c 166 @param Instance Dhcp4 instance.\r
ed729a0c 167\r
168**/\r
c4a62a12 169VOID\r
170PxeDhcpDone (\r
171 IN DHCP_PROTOCOL *Instance\r
172 );\r
173\r
235eaa63 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
842d83d6 187/**\r
188 Set the elapsed time based on the given instance and the pointer to the\r
189 elapsed time option.\r
190\r
191 @param[in] Elapsed The pointer to the position to append.\r
192 @param[in] Instance The pointer to the Dhcp4 instance.\r
193**/\r
194VOID\r
195SetElapsedTime (\r
196 IN UINT16 *Elapsed,\r
197 IN DHCP_PROTOCOL *Instance\r
198 );\r
199\r
83cbd279 200#endif\r