]>
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>
23 #define DHCP_WAIT_OFFER 3 // Time to wait the offers
24 #define DHCP_DEFAULT_LEASE 7 * 24 * 60 * 60 // Seven days as default.
25 #define DHCP_SERVER_PORT 67
26 #define DHCP_CLIENT_PORT 68
29 // BOOTP header "op" field
31 #define BOOTP_REQUEST 1
37 #define DHCP_MSG_DISCOVER 1
38 #define DHCP_MSG_OFFER 2
39 #define DHCP_MSG_REQUEST 3
40 #define DHCP_MSG_DECLINE 4
41 #define DHCP_MSG_ACK 5
42 #define DHCP_MSG_NAK 6
43 #define DHCP_MSG_RELEASE 7
44 #define DHCP_MSG_INFORM 8
47 // DHCP notify user type
49 #define DHCP_NOTIFY_COMPLETION 1
50 #define DHCP_NOTIFY_RENEWREBIND 2
51 #define DHCP_NOTIFY_ALL 3
53 #define DHCP_IS_BOOTP(Parameter) (((Parameter) == NULL) || ((Parameter)->DhcpType == 0))
55 #define DHCP_CONNECTED(State) \
56 (((State) == Dhcp4Bound) || ((State) == (Dhcp4Renewing)) || ((State) == Dhcp4Rebinding))
59 Set the DHCP state. If CallUser is true, it will try to notify
60 the user before change the state by DhcpNotifyUser. It returns
61 EFI_ABORTED if the user return EFI_ABORTED, otherwise, it returns
62 EFI_SUCCESS. If CallUser is FALSE, it isn't necessary to test
63 the return value of this function.
65 @param DhcpSb The DHCP service instance
66 @param State The new DHCP state to change to
67 @param CallUser Whether we need to call user
69 @retval EFI_SUCCESS The state is changed
70 @retval EFI_ABORTED The user asks to abort the DHCP process.
75 IN OUT DHCP_SERVICE
*DhcpSb
,
81 Build and transmit a DHCP message according to the current states.
82 This function implement the Table 5. of RFC 2131. Always transits
83 the state (as defined in Figure 5. of the same RFC) before sending
84 a DHCP message. The table is adjusted accordingly.
86 @param[in] DhcpSb The DHCP service instance
87 @param[in] Seed The seed packet which the new packet is based on
88 @param[in] Para The DHCP parameter of the Seed packet
89 @param[in] Type The message type to send
90 @param[in] Msg The human readable message to include in the packet
93 @retval EFI_OUT_OF_RESOURCES Failed to allocate resources for the packet
94 @retval EFI_ACCESS_DENIED Failed to transmit the packet through UDP
95 @retval EFI_SUCCESS The message is sent
96 @retval other Other error occurs
101 IN DHCP_SERVICE
*DhcpSb
,
102 IN EFI_DHCP4_PACKET
*Seed
,
103 IN DHCP_PARAMETER
*Para
,
109 Each DHCP service has three timer. Two of them are count down timer.
110 One for the packet retransmission. The other is to collect the offers.
111 The third timer increaments the lease life which is compared to T1, T2,
112 and lease to determine the time to renew and rebind the lease.
113 DhcpOnTimerTick will be called once every second.
115 @param[in] Event The timer event
116 @param[in] Context The context, which is the DHCP service instance.
127 Handle the received DHCP packets. This function drives the DHCP
130 @param UdpPacket The UDP packets received.
131 @param EndPoint The local/remote UDP access point
132 @param IoStatus The status of the UDP receive
133 @param Context The opaque parameter to the function.
140 UDP_END_POINT
*EndPoint
,
146 Send an initial DISCOVER or REQUEST message according to the
147 DHCP service's current state.
149 @param[in] DhcpSb The DHCP service instance
151 @retval EFI_SUCCESS The request has been sent
152 @retval other Some error occurs when sending the request.
157 IN DHCP_SERVICE
*DhcpSb
161 Clean up the DHCP related states, IoStatus isn't reset.
163 @param DhcpSb The DHCP instance service.
168 IN DHCP_SERVICE
*DhcpSb
172 Release the net buffer when packet is sent.
174 @param UdpPacket The UDP packets received.
175 @param EndPoint The local/remote UDP access point
176 @param IoStatus The status of the UDP receive
177 @param Context The opaque parameter to the function.
184 UDP_END_POINT
*EndPoint
,