]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.h
[Change summary]:
[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
434ce3fe 9Copyright (c) 2006 - 2009, 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
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
51// goes back to UNCONFIGED. It becomes DESTORY if it is (partly)\r
52// destoried.\r
53//\r
54#define DHCP_UNCONFIGED 0\r
55#define DHCP_CONFIGED 1\r
56#define DHCP_DESTORY 2\r
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
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
b45b45b2 72 UDP_IO *UdpIo; // The UDP IO used for TransmitReceive.\r
c4a62a12 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
b45b45b2 111 UDP_IO *UdpIo; // Udp child receiving all DHCP message\r
112 UDP_IO *LeaseIoPort; // Udp child with lease IP\r
434ce3fe 113 EFI_DHCP4_PACKET *LastPacket; // The last sent packet for retransmission\r
83cbd279 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
434ce3fe 129 UINT32 LastTimeout; // Record the init value of PacketToLive every time\r
83cbd279 130 INTN CurRetry;\r
131 INTN MaxRetries;\r
83cbd279 132 UINT32 LeaseLife;\r
133};\r
134\r
135typedef struct {\r
136 EFI_DHCP4_PACKET_OPTION **Option;\r
137 UINT32 OptionCount;\r
138 UINT32 Index;\r
139} DHCP_PARSE_CONTEXT;\r
140\r
141#define DHCP_INSTANCE_FROM_THIS(Proto) \\r
142 CR ((Proto), DHCP_PROTOCOL, Dhcp4Protocol, DHCP_PROTOCOL_SIGNATURE)\r
143\r
144#define DHCP_SERVICE_FROM_THIS(Sb) \\r
145 CR ((Sb), DHCP_SERVICE, ServiceBinding, DHCP_SERVICE_SIGNATURE)\r
146\r
147extern EFI_DHCP4_PROTOCOL mDhcp4ProtocolTemplate;\r
148\r
7bce0c5a 149/**\r
150 Give up the control of the DHCP service to let other child\r
151 resume. Don't change the service's DHCP state and the Client\r
152 address and option list configure as required by RFC2131.\r
153\r
154 @param DhcpSb The DHCP service instance.\r
155\r
7bce0c5a 156**/\r
83cbd279 157VOID\r
158DhcpYieldControl (\r
ed729a0c 159 IN DHCP_SERVICE *DhcpSb\r
83cbd279 160 );\r
161\r
ed729a0c 162/**\r
163 Complete a Dhcp4 transaction and signal the upper layer.\r
164 \r
165 @param Instance Dhcp4 instance.\r
ed729a0c 166\r
167**/\r
c4a62a12 168VOID\r
169PxeDhcpDone (\r
170 IN DHCP_PROTOCOL *Instance\r
171 );\r
172\r
83cbd279 173#endif\r