]>
git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.h
c041ba87ed8cd66ba791431c5ea224f58d624c22
3 Copyright (c) 2006 - 2008, 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.
19 The DHCP4 protocol implementation.
24 #ifndef __EFI_DHCP4_IO_H__
25 #define __EFI_DHCP4_IO_H__
29 #include <Protocol/ServiceBinding.h>
31 #include <Library/NetLib.h>
32 #include <Library/UdpIoLib.h>
33 #include <Library/BaseMemoryLib.h>
34 #include <Library/MemoryAllocationLib.h>
38 #define DHCP_WAIT_OFFER 3 // Time to wait the offers
39 #define DHCP_DEFAULT_LEASE 7 *24 *60 *60 // Seven days as default.
40 #define DHCP_SERVER_PORT 67
41 #define DHCP_CLIENT_PORT 68
45 // BOOTP header "op" field
55 DHCP_MSG_DISCOVER
= 1,
67 // DHCP notify user type
69 DHCP_NOTIFY_COMPLETION
= 1,
70 DHCP_NOTIFY_RENEWREBIND
,
74 #define DHCP_IS_BOOTP(Parameter) (((Parameter) == NULL) || ((Parameter)->DhcpType == 0))
76 #define DHCP_CONNECTED(State) \
77 (((State) == Dhcp4Bound) || ((State) == (Dhcp4Renewing)) || ((State) == Dhcp4Rebinding))
80 Set the DHCP state. If CallUser is true, it will try to notify
81 the user before change the state by DhcpNotifyUser. It returns
82 EFI_ABORTED if the user return EFI_ABORTED, otherwise, it returns
83 EFI_SUCCESS. If CallUser is FALSE, it isn't necessary to test
84 the return value of this function.
86 @param DhcpSb The DHCP service instance
87 @param State The new DHCP state to change to
88 @param CallUser Whether we need to call user
90 @retval EFI_SUCCESS The state is changed
91 @retval EFI_ABORTED The user asks to abort the DHCP process.
96 IN DHCP_SERVICE
*DhcpSb
,
102 Build and transmit a DHCP message according to the current states.
103 This function implement the Table 5. of RFC 2131. Always transits
104 the state (as defined in Figure 5. of the same RFC) before sending
105 a DHCP message. The table is adjusted accordingly.
107 @param DhcpSb The DHCP service instance
108 @param Seed The seed packet which the new packet is based on
109 @param Para The DHCP parameter of the Seed packet
110 @param Type The message type to send
111 @param Msg The human readable message to include in the packet
114 @retval EFI_OUT_OF_RESOURCES Failed to allocate resources for the packet
115 @retval EFI_ACCESS_DENIED Failed to transmit the packet through UDP
116 @retval EFI_SUCCESS The message is sent
121 IN DHCP_SERVICE
*DhcpSb
,
122 IN EFI_DHCP4_PACKET
*Seed
,
123 IN DHCP_PARAMETER
*Para
,
129 Each DHCP service has three timer. Two of them are count down timer.
130 One for the packet retransmission. The other is to collect the offers.
131 The third timer increaments the lease life which is compared to T1, T2,
132 and lease to determine the time to renew and rebind the lease.
133 DhcpOnTimerTick will be called once every second.
135 @param Event The timer event
136 @param Context The context, which is the DHCP service instance.
149 Handle the received DHCP packets. This function drivers the DHCP
152 @param UdpPacket The UDP packets received.
153 @param Points The local/remote UDP access points
154 @param IoStatus The status of the UDP receive
155 @param Context The opaque parameter to the function.
169 Send an initial DISCOVER or REQUEST message according to the
170 DHCP service's current state.
172 @param DhcpSb The DHCP service instance
174 @retval EFI_SUCCESS The request has been sent
179 IN DHCP_SERVICE
*DhcpSb
183 Clean up the DHCP related states, IoStatus isn't reset.
185 @param DhcpSb The DHCP instance service.
192 IN DHCP_SERVICE
*DhcpSb
196 Release the net buffer when packet is sent.
198 @param UdpPacket The UDP packets received.
199 @param Points The local/remote UDP access points
200 @param IoStatus The status of the UDP receive
201 @param Context The opaque parameter to the function.