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