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