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