3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 EFI DHCP protocol implementation
20 RFC 2131: Dynamic Host Configuration Protocol
21 RFC 2132: DHCP Options and BOOTP Vendor Extensions
22 RFC 1534: Interoperation Between DHCP and BOOTP
23 RFC 3396: Encoding Long Options in DHCP
28 #ifndef __EFI_DHCP4_IMPL_H__
29 #define __EFI_DHCP4_IMPL_H__
35 #include <Protocol/Dhcp4.h>
36 #include <Protocol/Udp4.h>
38 #include <Library/DebugLib.h>
39 #include <Library/UefiDriverEntryPoint.h>
40 #include <Library/UefiBootServicesTableLib.h>
41 #include <Library/UefiLib.h>
42 #include <Library/BaseLib.h>
43 #include <Library/NetLib.h>
45 typedef struct _DHCP_SERVICE DHCP_SERVICE
;
46 typedef struct _DHCP_PROTOCOL DHCP_PROTOCOL
;
48 #include "Dhcp4Option.h"
52 DHCP_SERVICE_SIGNATURE
= EFI_SIGNATURE_32 ('D', 'H', 'C', 'P'),
53 DHCP_PROTOCOL_SIGNATURE
= EFI_SIGNATURE_32 ('d', 'h', 'c', 'p'),
56 // The state of the DHCP service. It starts as UNCONFIGED. If
57 // and active child configures the service successfully, it
58 // goes to CONFIGED. If the active child configures NULL, it
59 // goes back to UNCONFIGED. It becomes DESTORY if it is (partly)
67 struct _DHCP_PROTOCOL
{
69 EFI_DHCP4_PROTOCOL Dhcp4Protocol
;
72 DHCP_SERVICE
*Service
;
76 EFI_EVENT CompletionEvent
;
77 EFI_EVENT RenewRebindEvent
;
79 EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN
*Token
;
80 UDP_IO_PORT
*UdpIo
; // The UDP IO used for TransmitReceive.
82 NET_BUF_QUEUE ResponseQueue
;
86 // DHCP driver is specical in that it is a singleton. Although it
87 // has a service binding, there can be only one active child.
89 struct _DHCP_SERVICE
{
91 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding
;
93 INTN ServiceState
; // CONFIGED, UNCONFIGED, and DESTORY
96 EFI_HANDLE Controller
;
99 NET_LIST_ENTRY Children
;
103 EFI_STATUS IoStatus
; // the result of last user operation
106 IP4_ADDR ClientAddr
; // lease IP or configured client address
110 EFI_DHCP4_PACKET
*LastOffer
; // The last received offer
111 EFI_DHCP4_PACKET
*Selected
;
112 DHCP_PARAMETER
*Para
;
117 INTN ExtraRefresh
; // This refresh is reqested by user
119 UDP_IO_PORT
*UdpIo
; // Udp child receiving all DHCP message
120 UDP_IO_PORT
*LeaseIoPort
; // Udp child with lease IP
121 NET_BUF
*LastPacket
; // The last sent packet for retransmission
126 DHCP_PROTOCOL
*ActiveChild
;
127 EFI_DHCP4_CONFIG_DATA ActiveConfig
;
128 UINT32 UserOptionLen
;
131 // Timer event and various timer
135 UINT32 PacketToLive
; // Retransmission timer for our packets
139 UINT32 WaitOffer
; // Time to collect the offers
144 EFI_DHCP4_PACKET_OPTION
**Option
;
147 } DHCP_PARSE_CONTEXT
;
149 #define DHCP_INSTANCE_FROM_THIS(Proto) \
150 CR ((Proto), DHCP_PROTOCOL, Dhcp4Protocol, DHCP_PROTOCOL_SIGNATURE)
152 #define DHCP_SERVICE_FROM_THIS(Sb) \
153 CR ((Sb), DHCP_SERVICE, ServiceBinding, DHCP_SERVICE_SIGNATURE)
155 extern EFI_DHCP4_PROTOCOL mDhcp4ProtocolTemplate
;
159 IN DHCP_SERVICE
*DhcpSb
164 IN DHCP_PROTOCOL
*Instance