2 EFI DHCP protocol implementation.
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.
9 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
10 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
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.
20 #ifndef __EFI_DHCP4_IMPL_H__
21 #define __EFI_DHCP4_IMPL_H__
27 #include <Protocol/Dhcp4.h>
28 #include <Protocol/Udp4.h>
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>
37 typedef struct _DHCP_SERVICE DHCP_SERVICE
;
38 typedef struct _DHCP_PROTOCOL DHCP_PROTOCOL
;
40 #include "Dhcp4Option.h"
43 #define DHCP_SERVICE_SIGNATURE SIGNATURE_32 ('D', 'H', 'C', 'P')
44 #define DHCP_PROTOCOL_SIGNATURE SIGNATURE_32 ('d', 'h', 'c', 'p')
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)
54 #define DHCP_UNCONFIGED 0
55 #define DHCP_CONFIGED 1
56 #define DHCP_DESTORY 2
59 struct _DHCP_PROTOCOL
{
61 EFI_DHCP4_PROTOCOL Dhcp4Protocol
;
64 DHCP_SERVICE
*Service
;
68 EFI_EVENT CompletionEvent
;
69 EFI_EVENT RenewRebindEvent
;
71 EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN
*Token
;
72 UDP_IO
*UdpIo
; // The UDP IO used for TransmitReceive.
74 NET_BUF_QUEUE ResponseQueue
;
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.
81 struct _DHCP_SERVICE
{
83 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding
;
85 INTN ServiceState
; // CONFIGED, UNCONFIGED, and DESTORY
88 EFI_HANDLE Controller
;
95 EFI_STATUS IoStatus
; // the result of last user operation
98 IP4_ADDR ClientAddr
; // lease IP or configured client address
102 EFI_DHCP4_PACKET
*LastOffer
; // The last received offer
103 EFI_DHCP4_PACKET
*Selected
;
104 DHCP_PARAMETER
*Para
;
109 INTN ExtraRefresh
; // This refresh is reqested by user
111 UDP_IO
*UdpIo
; // Udp child receiving all DHCP message
112 UDP_IO
*LeaseIoPort
; // Udp child with lease IP
113 EFI_DHCP4_PACKET
*LastPacket
; // The last sent packet for retransmission
117 UINT8 ClientAddressSendOut
[16];
119 DHCP_PROTOCOL
*ActiveChild
;
120 EFI_DHCP4_CONFIG_DATA ActiveConfig
;
121 UINT32 UserOptionLen
;
124 // Timer event and various timer
128 UINT32 PacketToLive
; // Retransmission timer for our packets
129 UINT32 LastTimeout
; // Record the init value of PacketToLive every time
136 EFI_DHCP4_PACKET_OPTION
**Option
;
139 } DHCP_PARSE_CONTEXT
;
141 #define DHCP_INSTANCE_FROM_THIS(Proto) \
142 CR ((Proto), DHCP_PROTOCOL, Dhcp4Protocol, DHCP_PROTOCOL_SIGNATURE)
144 #define DHCP_SERVICE_FROM_THIS(Sb) \
145 CR ((Sb), DHCP_SERVICE, ServiceBinding, DHCP_SERVICE_SIGNATURE)
147 extern EFI_DHCP4_PROTOCOL mDhcp4ProtocolTemplate
;
150 Give up the control of the DHCP service to let other child
151 resume. Don't change the service's DHCP state and the Client
152 address and option list configure as required by RFC2131.
154 @param DhcpSb The DHCP service instance.
159 IN DHCP_SERVICE
*DhcpSb
163 Complete a Dhcp4 transaction and signal the upper layer.
165 @param Instance Dhcp4 instance.
170 IN DHCP_PROTOCOL
*Instance
174 Free the resource related to the configure parameters.
175 DHCP driver will make a copy of the user's configure
176 such as the time out value.
178 @param Config The DHCP configure data
183 IN OUT EFI_DHCP4_CONFIG_DATA
*Config