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