]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.h
Roll back the DEBUG mask change which cause SerialIo read_conf test item failure.
[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
9Copyright (c) 2006 - 2008, Intel Corporation.<BR>\r
83cbd279 10All rights reserved. This 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
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
25#include <PiDxe.h>\r
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
7bce0c5a 46typedef enum {\r
83cbd279 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
51 // goes back to UNCONFIGED. It becomes DESTORY if it is (partly)\r
52 // destoried.\r
53 //\r
54 DHCP_UNCONFIGED = 0,\r
55 DHCP_CONFIGED,\r
56 DHCP_DESTORY\r
7bce0c5a 57} DHCP_STATE;\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
66 BOOLEAN InDestory;\r
67\r
68 EFI_EVENT CompletionEvent;\r
69 EFI_EVENT RenewRebindEvent;\r
70\r
71 EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN *Token;\r
c4a62a12 72 UDP_IO_PORT *UdpIo; // The UDP IO used for TransmitReceive.\r
73 UINT32 Timeout;\r
74 NET_BUF_QUEUE ResponseQueue;\r
83cbd279 75};\r
76\r
77//\r
78// DHCP driver is specical in that it is a singleton. Although it\r
79// has a service binding, there can be only one active child.\r
80//\r
81struct _DHCP_SERVICE {\r
82 UINT32 Signature;\r
83 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;\r
84\r
85 INTN ServiceState; // CONFIGED, UNCONFIGED, and DESTORY\r
86 BOOLEAN InDestory;\r
87\r
88 EFI_HANDLE Controller;\r
89 EFI_HANDLE Image;\r
90\r
e48e37fc 91 LIST_ENTRY Children;\r
83cbd279 92 UINTN NumChildren;\r
93\r
94 INTN DhcpState;\r
95 EFI_STATUS IoStatus; // the result of last user operation\r
96 UINT32 Xid;\r
97\r
98 IP4_ADDR ClientAddr; // lease IP or configured client address\r
99 IP4_ADDR Netmask;\r
100 IP4_ADDR ServerAddr;\r
101\r
102 EFI_DHCP4_PACKET *LastOffer; // The last received offer\r
103 EFI_DHCP4_PACKET *Selected;\r
104 DHCP_PARAMETER *Para;\r
105\r
106 UINT32 Lease;\r
107 UINT32 T1;\r
108 UINT32 T2;\r
109 INTN ExtraRefresh; // This refresh is reqested by user\r
110\r
111 UDP_IO_PORT *UdpIo; // Udp child receiving all DHCP message\r
112 UDP_IO_PORT *LeaseIoPort; // Udp child with lease IP\r
113 NET_BUF *LastPacket; // The last sent packet for retransmission\r
114 EFI_MAC_ADDRESS Mac;\r
115 UINT8 HwType;\r
116 UINT8 HwLen;\r
982a9eae 117 UINT8 ClientAddressSendOut[16];\r
83cbd279 118\r
119 DHCP_PROTOCOL *ActiveChild;\r
120 EFI_DHCP4_CONFIG_DATA ActiveConfig;\r
121 UINT32 UserOptionLen;\r
122\r
123 //\r
124 // Timer event and various timer\r
125 //\r
126 EFI_EVENT Timer;\r
127\r
128 UINT32 PacketToLive; // Retransmission timer for our packets\r
129 INTN CurRetry;\r
130 INTN MaxRetries;\r
83cbd279 131 UINT32 LeaseLife;\r
132};\r
133\r
134typedef struct {\r
135 EFI_DHCP4_PACKET_OPTION **Option;\r
136 UINT32 OptionCount;\r
137 UINT32 Index;\r
138} DHCP_PARSE_CONTEXT;\r
139\r
140#define DHCP_INSTANCE_FROM_THIS(Proto) \\r
141 CR ((Proto), DHCP_PROTOCOL, Dhcp4Protocol, DHCP_PROTOCOL_SIGNATURE)\r
142\r
143#define DHCP_SERVICE_FROM_THIS(Sb) \\r
144 CR ((Sb), DHCP_SERVICE, ServiceBinding, DHCP_SERVICE_SIGNATURE)\r
145\r
146extern EFI_DHCP4_PROTOCOL mDhcp4ProtocolTemplate;\r
147\r
7bce0c5a 148/**\r
149 Give up the control of the DHCP service to let other child\r
150 resume. Don't change the service's DHCP state and the Client\r
151 address and option list configure as required by RFC2131.\r
152\r
153 @param DhcpSb The DHCP service instance.\r
154\r
7bce0c5a 155**/\r
83cbd279 156VOID\r
157DhcpYieldControl (\r
ed729a0c 158 IN DHCP_SERVICE *DhcpSb\r
83cbd279 159 );\r
160\r
ed729a0c 161/**\r
162 Complete a Dhcp4 transaction and signal the upper layer.\r
163 \r
164 @param Instance Dhcp4 instance.\r
ed729a0c 165\r
166**/\r
c4a62a12 167VOID\r
168PxeDhcpDone (\r
169 IN DHCP_PROTOCOL *Instance\r
170 );\r
171\r
83cbd279 172#endif\r