]>
git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.h
5f8ac13e84ef03f88acb711083846d9fa0e3b0f9
2 The DHCP4 protocol implementation.
4 Copyright (c) 2006 - 2008, Intel Corporation.<BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef __EFI_DHCP4_IO_H__
16 #define __EFI_DHCP4_IO_H__
20 #include <Protocol/ServiceBinding.h>
22 #include <Library/NetLib.h>
23 #include <Library/UdpIoLib.h>
24 #include <Library/BaseMemoryLib.h>
25 #include <Library/MemoryAllocationLib.h>
29 #define DHCP_WAIT_OFFER 3 // Time to wait the offers
30 #define DHCP_DEFAULT_LEASE 7 * 24 * 60 * 60 // Seven days as default.
31 #define DHCP_SERVER_PORT 67
32 #define DHCP_CLIENT_PORT 68
36 // BOOTP header "op" field
46 DHCP_MSG_DISCOVER
= 1,
58 // DHCP notify user type
60 DHCP_NOTIFY_COMPLETION
= 1,
61 DHCP_NOTIFY_RENEWREBIND
,
65 #define DHCP_IS_BOOTP(Parameter) (((Parameter) == NULL) || ((Parameter)->DhcpType == 0))
67 #define DHCP_CONNECTED(State) \
68 (((State) == Dhcp4Bound) || ((State) == (Dhcp4Renewing)) || ((State) == Dhcp4Rebinding))
71 Set the DHCP state. If CallUser is true, it will try to notify
72 the user before change the state by DhcpNotifyUser. It returns
73 EFI_ABORTED if the user return EFI_ABORTED, otherwise, it returns
74 EFI_SUCCESS. If CallUser is FALSE, it isn't necessary to test
75 the return value of this function.
77 @param DhcpSb The DHCP service instance
78 @param State The new DHCP state to change to
79 @param CallUser Whether we need to call user
81 @retval EFI_SUCCESS The state is changed
82 @retval EFI_ABORTED The user asks to abort the DHCP process.
87 IN OUT DHCP_SERVICE
*DhcpSb
,
93 Build and transmit a DHCP message according to the current states.
94 This function implement the Table 5. of RFC 2131. Always transits
95 the state (as defined in Figure 5. of the same RFC) before sending
96 a DHCP message. The table is adjusted accordingly.
98 @param[in] DhcpSb The DHCP service instance
99 @param[in] Seed The seed packet which the new packet is based on
100 @param[in] Para The DHCP parameter of the Seed packet
101 @param[in] Type The message type to send
102 @param[in] Msg The human readable message to include in the packet
105 @retval EFI_OUT_OF_RESOURCES Failed to allocate resources for the packet
106 @retval EFI_ACCESS_DENIED Failed to transmit the packet through UDP
107 @retval EFI_SUCCESS The message is sent
108 @retval other Other error occurs
113 IN DHCP_SERVICE
*DhcpSb
,
114 IN EFI_DHCP4_PACKET
*Seed
,
115 IN DHCP_PARAMETER
*Para
,
121 Each DHCP service has three timer. Two of them are count down timer.
122 One for the packet retransmission. The other is to collect the offers.
123 The third timer increaments the lease life which is compared to T1, T2,
124 and lease to determine the time to renew and rebind the lease.
125 DhcpOnTimerTick will be called once every second.
127 @param[in] Event The timer event
128 @param[in] Context The context, which is the DHCP service instance.
139 Handle the received DHCP packets. This function drives the DHCP
142 @param UdpPacket The UDP packets received.
143 @param Points The local/remote UDP access points
144 @param IoStatus The status of the UDP receive
145 @param Context The opaque parameter to the function.
157 Send an initial DISCOVER or REQUEST message according to the
158 DHCP service's current state.
160 @param[in] DhcpSb The DHCP service instance
162 @retval EFI_SUCCESS The request has been sent
163 @retval other Some error occurs when sending the request.
168 IN DHCP_SERVICE
*DhcpSb
172 Clean up the DHCP related states, IoStatus isn't reset.
174 @param DhcpSb The DHCP instance service.
179 IN DHCP_SERVICE
*DhcpSb
183 Release the net buffer when packet is sent.
185 @param UdpPacket The UDP packets received.
186 @param Points The local/remote UDP access points
187 @param IoStatus The status of the UDP receive
188 @param Context The opaque parameter to the function.