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