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