]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.h
Update the copyright notice format
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Dhcp4Dxe / Dhcp4Io.h
... / ...
CommitLineData
1/** @file\r
2 The DHCP4 protocol implementation.\r
3 \r
4Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
5This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef __EFI_DHCP4_IO_H__\r
16#define __EFI_DHCP4_IO_H__\r
17\r
18#include <Uefi.h>\r
19\r
20#include <Protocol/ServiceBinding.h>\r
21\r
22#include <Library/NetLib.h>\r
23#include <Library/UdpIoLib.h>\r
24#include <Library/BaseMemoryLib.h>\r
25#include <Library/MemoryAllocationLib.h>\r
26\r
27\r
28\r
29#define DHCP_WAIT_OFFER 3 // Time to wait the offers\r
30#define DHCP_DEFAULT_LEASE 7 * 24 * 60 * 60 // Seven days as default.\r
31#define DHCP_SERVER_PORT 67\r
32#define DHCP_CLIENT_PORT 68\r
33\r
34//\r
35// BOOTP header "op" field\r
36//\r
37#define BOOTP_REQUEST 1\r
38#define BOOTP_REPLY 2\r
39\r
40//\r
41// DHCP message types\r
42//\r
43#define DHCP_MSG_DISCOVER 1\r
44#define DHCP_MSG_OFFER 2\r
45#define DHCP_MSG_REQUEST 3\r
46#define DHCP_MSG_DECLINE 4\r
47#define DHCP_MSG_ACK 5\r
48#define DHCP_MSG_NAK 6\r
49#define DHCP_MSG_RELEASE 7\r
50#define DHCP_MSG_INFORM 8\r
51\r
52//\r
53// DHCP notify user type\r
54//\r
55#define DHCP_NOTIFY_COMPLETION 1\r
56#define DHCP_NOTIFY_RENEWREBIND 2\r
57#define DHCP_NOTIFY_ALL 3\r
58\r
59#define DHCP_IS_BOOTP(Parameter) (((Parameter) == NULL) || ((Parameter)->DhcpType == 0))\r
60\r
61#define DHCP_CONNECTED(State) \\r
62 (((State) == Dhcp4Bound) || ((State) == (Dhcp4Renewing)) || ((State) == Dhcp4Rebinding))\r
63\r
64/**\r
65 Set the DHCP state. If CallUser is true, it will try to notify\r
66 the user before change the state by DhcpNotifyUser. It returns\r
67 EFI_ABORTED if the user return EFI_ABORTED, otherwise, it returns\r
68 EFI_SUCCESS. If CallUser is FALSE, it isn't necessary to test\r
69 the return value of this function.\r
70\r
71 @param DhcpSb The DHCP service instance\r
72 @param State The new DHCP state to change to\r
73 @param CallUser Whether we need to call user\r
74\r
75 @retval EFI_SUCCESS The state is changed\r
76 @retval EFI_ABORTED The user asks to abort the DHCP process.\r
77\r
78**/\r
79EFI_STATUS\r
80DhcpSetState (\r
81 IN OUT DHCP_SERVICE *DhcpSb,\r
82 IN INTN State,\r
83 IN BOOLEAN CallUser\r
84 );\r
85\r
86/**\r
87 Build and transmit a DHCP message according to the current states.\r
88 This function implement the Table 5. of RFC 2131. Always transits\r
89 the state (as defined in Figure 5. of the same RFC) before sending\r
90 a DHCP message. The table is adjusted accordingly.\r
91\r
92 @param[in] DhcpSb The DHCP service instance\r
93 @param[in] Seed The seed packet which the new packet is based on\r
94 @param[in] Para The DHCP parameter of the Seed packet\r
95 @param[in] Type The message type to send\r
96 @param[in] Msg The human readable message to include in the packet\r
97 sent.\r
98\r
99 @retval EFI_OUT_OF_RESOURCES Failed to allocate resources for the packet\r
100 @retval EFI_ACCESS_DENIED Failed to transmit the packet through UDP\r
101 @retval EFI_SUCCESS The message is sent\r
102 @retval other Other error occurs\r
103\r
104**/\r
105EFI_STATUS\r
106DhcpSendMessage (\r
107 IN DHCP_SERVICE *DhcpSb,\r
108 IN EFI_DHCP4_PACKET *Seed,\r
109 IN DHCP_PARAMETER *Para,\r
110 IN UINT8 Type,\r
111 IN UINT8 *Msg\r
112 );\r
113\r
114/**\r
115 Each DHCP service has three timer. Two of them are count down timer.\r
116 One for the packet retransmission. The other is to collect the offers.\r
117 The third timer increaments the lease life which is compared to T1, T2,\r
118 and lease to determine the time to renew and rebind the lease.\r
119 DhcpOnTimerTick will be called once every second.\r
120\r
121 @param[in] Event The timer event\r
122 @param[in] Context The context, which is the DHCP service instance.\r
123\r
124**/\r
125VOID\r
126EFIAPI\r
127DhcpOnTimerTick (\r
128 IN EFI_EVENT Event,\r
129 IN VOID *Context\r
130 );\r
131\r
132/**\r
133 Handle the received DHCP packets. This function drives the DHCP\r
134 state machine.\r
135\r
136 @param UdpPacket The UDP packets received.\r
137 @param EndPoint The local/remote UDP access point\r
138 @param IoStatus The status of the UDP receive\r
139 @param Context The opaque parameter to the function.\r
140\r
141**/\r
142VOID\r
143EFIAPI\r
144DhcpInput (\r
145 NET_BUF *UdpPacket,\r
146 UDP_END_POINT *EndPoint,\r
147 EFI_STATUS IoStatus,\r
148 VOID *Context\r
149 );\r
150\r
151/**\r
152 Send an initial DISCOVER or REQUEST message according to the\r
153 DHCP service's current state.\r
154\r
155 @param[in] DhcpSb The DHCP service instance\r
156\r
157 @retval EFI_SUCCESS The request has been sent\r
158 @retval other Some error occurs when sending the request.\r
159\r
160**/\r
161EFI_STATUS\r
162DhcpInitRequest (\r
163 IN DHCP_SERVICE *DhcpSb\r
164 );\r
165\r
166/**\r
167 Clean up the DHCP related states, IoStatus isn't reset.\r
168\r
169 @param DhcpSb The DHCP instance service.\r
170\r
171**/\r
172VOID\r
173DhcpCleanLease (\r
174 IN DHCP_SERVICE *DhcpSb\r
175 );\r
176\r
177/**\r
178 Release the net buffer when packet is sent.\r
179\r
180 @param UdpPacket The UDP packets received.\r
181 @param EndPoint The local/remote UDP access point\r
182 @param IoStatus The status of the UDP receive\r
183 @param Context The opaque parameter to the function.\r
184\r
185**/\r
186VOID\r
187EFIAPI\r
188DhcpOnPacketSent (\r
189 NET_BUF *Packet,\r
190 UDP_END_POINT *EndPoint,\r
191 EFI_STATUS IoStatus,\r
192 VOID *Context\r
193 );\r
194\r
195#endif\r