VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.h@ 91230

Last change on this file since 91230 was 85718, checked in by vboxsync, 5 years ago

Devices/EFI: Merge edk-stable202005 and make it build, bugref:4643

  • Property svn:eol-style set to native
File size: 9.7 KB
Line 
1/** @file
2 Dhcp6 support functions declaration.
3
4 Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8**/
9
10#ifndef __EFI_DHCP6_UTILITY_H__
11#define __EFI_DHCP6_UTILITY_H__
12
13
14#define DHCP6_10_BIT_MASK 0x3ff
15#define DHCP6_DAD_ADDITIONAL_DELAY 30000000 // 3 seconds
16
17/**
18 Generate client Duid in the format of Duid-llt.
19
20 @param[in] Mode The pointer to the mode of SNP.
21
22 @retval NULL if failed to generate client Id.
23 @retval Others The pointer to the new client id.
24
25**/
26EFI_DHCP6_DUID *
27Dhcp6GenerateClientId (
28 IN EFI_SIMPLE_NETWORK_MODE *Mode
29 );
30
31/**
32 Copy the Dhcp6 configure data.
33
34 @param[in] DstCfg The pointer to the destination configure data.
35 @param[in] SorCfg The pointer to the source configure data.
36
37 @retval EFI_SUCCESS Copy the content from SorCfg from DstCfg successfully.
38 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
39
40**/
41EFI_STATUS
42Dhcp6CopyConfigData (
43 IN EFI_DHCP6_CONFIG_DATA *DstCfg,
44 IN EFI_DHCP6_CONFIG_DATA *SorCfg
45 );
46
47/**
48 Clean up the configure data.
49
50 @param[in, out] CfgData The pointer to the configure data.
51
52**/
53VOID
54Dhcp6CleanupConfigData (
55 IN OUT EFI_DHCP6_CONFIG_DATA *CfgData
56 );
57
58/**
59 Clean up the mode data.
60
61 @param[in, out] ModeData The pointer to the mode data.
62
63**/
64VOID
65Dhcp6CleanupModeData (
66 IN OUT EFI_DHCP6_MODE_DATA *ModeData
67 );
68
69/**
70 Calculate the expire time by the algorithm defined in rfc.
71
72 @param[in] Base The base value of the time.
73 @param[in] IsFirstRt If TRUE, it is the first time to calculate expire time.
74 @param[in] NeedSigned If TRUE, the signed factor is needed.
75
76 @return Expire The calculated result for the new expire time.
77
78**/
79UINT32
80Dhcp6CalculateExpireTime (
81 IN UINT32 Base,
82 IN BOOLEAN IsFirstRt,
83 IN BOOLEAN NeedSigned
84 );
85
86/**
87 Calculate the lease time by the algorithm defined in rfc.
88
89 @param[in] IaCb The pointer to the Ia control block.
90
91**/
92VOID
93Dhcp6CalculateLeaseTime (
94 IN DHCP6_IA_CB *IaCb
95 );
96
97/**
98 Check whether the addresses are all included by the configured Ia.
99
100 @param[in] Ia The pointer to the Ia.
101 @param[in] AddressCount The number of addresses.
102 @param[in] Addresses The pointer to the addresses buffer.
103
104 @retval EFI_SUCCESS The addresses are all included by the configured IA.
105 @retval EFI_NOT_FOUND The addresses are not included by the configured IA.
106
107**/
108EFI_STATUS
109Dhcp6CheckAddress (
110 IN EFI_DHCP6_IA *Ia,
111 IN UINT32 AddressCount,
112 IN EFI_IPv6_ADDRESS *Addresses
113 );
114
115/**
116 Deprive the addresses from current Ia, and generate another eliminated Ia.
117
118 @param[in] Ia The pointer to the Ia.
119 @param[in] AddressCount The number of addresses.
120 @param[in] Addresses The pointer to the addresses buffer.
121
122 @retval NULL If failed to generate the deprived Ia.
123 @retval others The pointer to the deprived Ia.
124
125**/
126EFI_DHCP6_IA *
127Dhcp6DepriveAddress (
128 IN EFI_DHCP6_IA *Ia,
129 IN UINT32 AddressCount,
130 IN EFI_IPv6_ADDRESS *Addresses
131 );
132
133/**
134 The dummy ext buffer free callback routine.
135
136 @param[in] Arg The pointer to the parameter.
137
138**/
139VOID
140EFIAPI
141Dhcp6DummyExtFree (
142 IN VOID *Arg
143 );
144
145/**
146 The callback routine once message transmitted.
147
148 @param[in] Wrap The pointer to the received net buffer.
149 @param[in] EndPoint The pointer to the udp end point.
150 @param[in] IoStatus The return status from udp io.
151 @param[in] Context The opaque parameter to the function.
152
153**/
154VOID
155EFIAPI
156Dhcp6OnTransmitted (
157 IN NET_BUF *Wrap,
158 IN UDP_END_POINT *EndPoint,
159 IN EFI_STATUS IoStatus,
160 IN VOID *Context
161 );
162
163/**
164 Append the appointed option to the buf, and move the buf to the end.
165
166 @param[in, out] Buf The pointer to buffer.
167 @param[in] OptType The option type.
168 @param[in] OptLen The length of option content.s
169 @param[in] Data The pointer to the option content.
170
171 @return Buf The position to append the next option.
172
173**/
174UINT8 *
175Dhcp6AppendOption (
176 IN OUT UINT8 *Buf,
177 IN UINT16 OptType,
178 IN UINT16 OptLen,
179 IN UINT8 *Data
180 );
181
182/**
183 Append the Ia option to Buf, and move Buf to the end.
184
185 @param[in, out] Buf The pointer to the position to append.
186 @param[in] Ia The pointer to the Ia.
187 @param[in] T1 The time of T1.
188 @param[in] T2 The time of T2.
189 @param[in] MessageType Message type of DHCP6 package.
190
191 @return Buf The position to append the next Ia option.
192
193**/
194UINT8 *
195Dhcp6AppendIaOption (
196 IN OUT UINT8 *Buf,
197 IN EFI_DHCP6_IA *Ia,
198 IN UINT32 T1,
199 IN UINT32 T2,
200 IN UINT32 MessageType
201 );
202
203/**
204 Append the appointed Elapsed time option to Buf, and move Buf to the end.
205
206 @param[in, out] Buf The pointer to the position to append.
207 @param[in] Instance The pointer to the Dhcp6 instance.
208 @param[out] Elapsed The pointer to the elapsed time value in
209 the generated packet.
210
211 @return Buf The position to append the next Ia option.
212
213**/
214UINT8 *
215Dhcp6AppendETOption (
216 IN OUT UINT8 *Buf,
217 IN DHCP6_INSTANCE *Instance,
218 OUT UINT16 **Elapsed
219 );
220
221/**
222 Set the elapsed time based on the given instance and the pointer to the
223 elapsed time option.
224
225 @param[in] Elapsed The pointer to the position to append.
226 @param[in] Instance The pointer to the Dhcp6 instance.
227**/
228VOID
229SetElapsedTime (
230 IN UINT16 *Elapsed,
231 IN DHCP6_INSTANCE *Instance
232 );
233
234/**
235 Seek the address of the first byte of the option header.
236
237 @param[in] Buf The pointer to buffer.
238 @param[in] SeekLen The length to seek.
239 @param[in] OptType The option type.
240
241 @retval NULL If failed to seek the option.
242 @retval others The position to the option.
243
244**/
245UINT8 *
246Dhcp6SeekOption (
247 IN UINT8 *Buf,
248 IN UINT32 SeekLen,
249 IN UINT16 OptType
250 );
251
252/**
253 Seek the address of the first byte of the Ia option header.
254
255 @param[in] Buf The pointer to the buffer.
256 @param[in] SeekLen The length to seek.
257 @param[in] IaDesc The pointer to the Ia descriptor.
258
259 @retval NULL If failed to seek the Ia option.
260 @retval others The position to the Ia option.
261
262**/
263UINT8 *
264Dhcp6SeekIaOption (
265 IN UINT8 *Buf,
266 IN UINT32 SeekLen,
267 IN EFI_DHCP6_IA_DESCRIPTOR *IaDesc
268 );
269
270/**
271 Parse the address option and update the address info.
272
273 @param[in] CurrentIa The pointer to the Ia Address in control block.
274 @param[in] IaInnerOpt The pointer to the buffer.
275 @param[in] IaInnerLen The length to parse.
276 @param[out] AddrNum The number of addresses.
277 @param[in, out] AddrBuf The pointer to the address buffer.
278
279**/
280VOID
281Dhcp6ParseAddrOption (
282 IN EFI_DHCP6_IA *CurrentIa,
283 IN UINT8 *IaInnerOpt,
284 IN UINT16 IaInnerLen,
285 OUT UINT32 *AddrNum,
286 IN OUT EFI_DHCP6_IA_ADDRESS *AddrBuf
287 );
288
289/**
290 Create a control block for the Ia according to the corresponding options.
291
292 @param[in] Instance The pointer to DHCP6 Instance.
293 @param[in] IaInnerOpt The pointer to the inner options in the Ia option.
294 @param[in] IaInnerLen The length of all the inner options in the Ia option.
295 @param[in] T1 T1 time in the Ia option.
296 @param[in] T2 T2 time in the Ia option.
297
298 @retval EFI_NOT_FOUND No valid IA option is found.
299 @retval EFI_SUCCESS Create an IA control block successfully.
300 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
301 @retval EFI_DEVICE_ERROR An unexpected error.
302
303**/
304EFI_STATUS
305Dhcp6GenerateIaCb (
306 IN DHCP6_INSTANCE *Instance,
307 IN UINT8 *IaInnerOpt,
308 IN UINT16 IaInnerLen,
309 IN UINT32 T1,
310 IN UINT32 T2
311 );
312
313
314/**
315 Cache the current IA configuration information.
316
317 @param[in] Instance The pointer to DHCP6 Instance.
318
319 @retval EFI_SUCCESS Cache the current IA successfully.
320 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
321
322**/
323EFI_STATUS
324Dhcp6CacheIa (
325 IN DHCP6_INSTANCE *Instance
326 );
327
328
329/**
330 Append CacheIa to the current IA. Meanwhile, clear CacheIa.ValidLifetime to 0.
331
332 @param[in] Instance The pointer to DHCP6 instance.
333
334**/
335VOID
336Dhcp6AppendCacheIa (
337 IN DHCP6_INSTANCE *Instance
338 );
339
340/**
341 Calculate the Dhcp6 get mapping timeout by adding additional delay to the IP6 DAD transmits count.
342
343 @param[in] Ip6Cfg The pointer to Ip6 config protocol.
344 @param[out] TimeOut The time out value in 100ns units.
345
346 @retval EFI_INVALID_PARAMETER Input parameters are invalid.
347 @retval EFI_SUCCESS Calculate the time out value successfully.
348**/
349EFI_STATUS
350Dhcp6GetMappingTimeOut (
351 IN EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg,
352 OUT UINTN *TimeOut
353 );
354#endif
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette