]>
git.proxmox.com Git - mirror_edk2.git/blob - NetworkPkg/Dhcp4Dxe/Dhcp4Io.h
2 The DHCP4 protocol implementation.
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #ifndef __EFI_DHCP4_IO_H__
10 #define __EFI_DHCP4_IO_H__
14 #include <Protocol/ServiceBinding.h>
16 #include <Library/NetLib.h>
17 #include <Library/UdpIoLib.h>
18 #include <Library/BaseMemoryLib.h>
19 #include <Library/MemoryAllocationLib.h>
21 #define DHCP_WAIT_OFFER 3 // Time to wait the offers
22 #define DHCP_DEFAULT_LEASE 7 * 24 * 60 * 60 // Seven days as default.
23 #define DHCP_SERVER_PORT 67
24 #define DHCP_CLIENT_PORT 68
27 // BOOTP header "op" field
29 #define BOOTP_REQUEST 1
35 #define DHCP_MSG_DISCOVER 1
36 #define DHCP_MSG_OFFER 2
37 #define DHCP_MSG_REQUEST 3
38 #define DHCP_MSG_DECLINE 4
39 #define DHCP_MSG_ACK 5
40 #define DHCP_MSG_NAK 6
41 #define DHCP_MSG_RELEASE 7
42 #define DHCP_MSG_INFORM 8
45 // DHCP notify user type
47 #define DHCP_NOTIFY_COMPLETION 1
48 #define DHCP_NOTIFY_RENEWREBIND 2
49 #define DHCP_NOTIFY_ALL 3
51 #define DHCP_IS_BOOTP(Parameter) (((Parameter) == NULL) || ((Parameter)->DhcpType == 0))
53 #define DHCP_CONNECTED(State) \
54 (((State) == Dhcp4Bound) || ((State) == (Dhcp4Renewing)) || ((State) == Dhcp4Rebinding))
57 Set the DHCP state. If CallUser is true, it will try to notify
58 the user before change the state by DhcpNotifyUser. It returns
59 EFI_ABORTED if the user return EFI_ABORTED, otherwise, it returns
60 EFI_SUCCESS. If CallUser is FALSE, it isn't necessary to test
61 the return value of this function.
63 @param DhcpSb The DHCP service instance
64 @param State The new DHCP state to change to
65 @param CallUser Whether we need to call user
67 @retval EFI_SUCCESS The state is changed
68 @retval EFI_ABORTED The user asks to abort the DHCP process.
73 IN OUT DHCP_SERVICE
*DhcpSb
,
79 Build and transmit a DHCP message according to the current states.
80 This function implement the Table 5. of RFC 2131. Always transits
81 the state (as defined in Figure 5. of the same RFC) before sending
82 a DHCP message. The table is adjusted accordingly.
84 @param[in] DhcpSb The DHCP service instance
85 @param[in] Seed The seed packet which the new packet is based on
86 @param[in] Para The DHCP parameter of the Seed packet
87 @param[in] Type The message type to send
88 @param[in] Msg The human readable message to include in the packet
91 @retval EFI_OUT_OF_RESOURCES Failed to allocate resources for the packet
92 @retval EFI_ACCESS_DENIED Failed to transmit the packet through UDP
93 @retval EFI_SUCCESS The message is sent
94 @retval other Other error occurs
99 IN DHCP_SERVICE
*DhcpSb
,
100 IN EFI_DHCP4_PACKET
*Seed
,
101 IN DHCP_PARAMETER
*Para
,
107 Each DHCP service has three timer. Two of them are count down timer.
108 One for the packet retransmission. The other is to collect the offers.
109 The third timer increments the lease life which is compared to T1, T2,
110 and lease to determine the time to renew and rebind the lease.
111 DhcpOnTimerTick will be called once every second.
113 @param[in] Event The timer event
114 @param[in] Context The context, which is the DHCP service instance.
125 Handle the received DHCP packets. This function drives the DHCP
128 @param UdpPacket The UDP packets received.
129 @param EndPoint The local/remote UDP access point
130 @param IoStatus The status of the UDP receive
131 @param Context The opaque parameter to the function.
138 UDP_END_POINT
*EndPoint
,
144 Send an initial DISCOVER or REQUEST message according to the
145 DHCP service's current state.
147 @param[in] DhcpSb The DHCP service instance
149 @retval EFI_SUCCESS The request has been sent
150 @retval other Some error occurs when sending the request.
155 IN DHCP_SERVICE
*DhcpSb
159 Clean up the DHCP related states, IoStatus isn't reset.
161 @param DhcpSb The DHCP instance service.
166 IN DHCP_SERVICE
*DhcpSb
170 Release the net buffer when packet is sent.
172 @param UdpPacket The UDP packets received.
173 @param EndPoint The local/remote UDP access point
174 @param IoStatus The status of the UDP receive
175 @param Context The opaque parameter to the function.
182 UDP_END_POINT
*EndPoint
,