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