]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Dhcp6 support functions declaration.\r | |
3 | \r | |
4 | Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r | |
5 | \r | |
6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
7 | \r | |
8 | **/\r | |
9 | \r | |
10 | #ifndef __EFI_DHCP6_UTILITY_H__\r | |
11 | #define __EFI_DHCP6_UTILITY_H__\r | |
12 | \r | |
13 | #define DHCP6_10_BIT_MASK 0x3ff\r | |
14 | #define DHCP6_DAD_ADDITIONAL_DELAY 30000000 // 3 seconds\r | |
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 | |
25 | EFI_DHCP6_DUID *\r | |
26 | Dhcp6GenerateClientId (\r | |
27 | IN EFI_SIMPLE_NETWORK_MODE *Mode\r | |
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 | |
40 | EFI_STATUS\r | |
41 | Dhcp6CopyConfigData (\r | |
42 | IN EFI_DHCP6_CONFIG_DATA *DstCfg,\r | |
43 | IN EFI_DHCP6_CONFIG_DATA *SorCfg\r | |
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 | |
52 | VOID\r | |
53 | Dhcp6CleanupConfigData (\r | |
54 | IN OUT EFI_DHCP6_CONFIG_DATA *CfgData\r | |
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 | |
63 | VOID\r | |
64 | Dhcp6CleanupModeData (\r | |
65 | IN OUT EFI_DHCP6_MODE_DATA *ModeData\r | |
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 | |
73 | @param[in] NeedSigned If TRUE, the signed factor is needed.\r | |
74 | \r | |
75 | @return Expire The calculated result for the new expire time.\r | |
76 | \r | |
77 | **/\r | |
78 | UINT32\r | |
79 | Dhcp6CalculateExpireTime (\r | |
80 | IN UINT32 Base,\r | |
81 | IN BOOLEAN IsFirstRt,\r | |
82 | IN BOOLEAN NeedSigned\r | |
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 | |
91 | VOID\r | |
92 | Dhcp6CalculateLeaseTime (\r | |
93 | IN DHCP6_IA_CB *IaCb\r | |
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 | |
107 | EFI_STATUS\r | |
108 | Dhcp6CheckAddress (\r | |
109 | IN EFI_DHCP6_IA *Ia,\r | |
110 | IN UINT32 AddressCount,\r | |
111 | IN EFI_IPv6_ADDRESS *Addresses\r | |
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 | |
125 | EFI_DHCP6_IA *\r | |
126 | Dhcp6DepriveAddress (\r | |
127 | IN EFI_DHCP6_IA *Ia,\r | |
128 | IN UINT32 AddressCount,\r | |
129 | IN EFI_IPv6_ADDRESS *Addresses\r | |
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 | |
138 | VOID\r | |
139 | EFIAPI\r | |
140 | Dhcp6DummyExtFree (\r | |
141 | IN VOID *Arg\r | |
142 | );\r | |
143 | \r | |
144 | /**\r | |
145 | The callback routine once message transmitted.\r | |
146 | \r | |
147 | @param[in] Wrap The pointer to the received net buffer.\r | |
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 | |
153 | VOID\r | |
154 | EFIAPI\r | |
155 | Dhcp6OnTransmitted (\r | |
156 | IN NET_BUF *Wrap,\r | |
157 | IN UDP_END_POINT *EndPoint,\r | |
158 | IN EFI_STATUS IoStatus,\r | |
159 | IN VOID *Context\r | |
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 | |
167 | @param[in] OptLen The length of option content.s\r | |
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 | |
173 | UINT8 *\r | |
174 | Dhcp6AppendOption (\r | |
175 | IN OUT UINT8 *Buf,\r | |
176 | IN UINT16 OptType,\r | |
177 | IN UINT16 OptLen,\r | |
178 | IN UINT8 *Data\r | |
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 | |
188 | @param[in] MessageType Message type of DHCP6 package.\r | |
189 | \r | |
190 | @return Buf The position to append the next Ia option.\r | |
191 | \r | |
192 | **/\r | |
193 | UINT8 *\r | |
194 | Dhcp6AppendIaOption (\r | |
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 | |
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 | |
213 | UINT8 *\r | |
214 | Dhcp6AppendETOption (\r | |
215 | IN OUT UINT8 *Buf,\r | |
216 | IN DHCP6_INSTANCE *Instance,\r | |
217 | OUT UINT16 **Elapsed\r | |
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 | |
227 | VOID\r | |
228 | SetElapsedTime (\r | |
229 | IN UINT16 *Elapsed,\r | |
230 | IN DHCP6_INSTANCE *Instance\r | |
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 | |
244 | UINT8 *\r | |
245 | Dhcp6SeekOption (\r | |
246 | IN UINT8 *Buf,\r | |
247 | IN UINT32 SeekLen,\r | |
248 | IN UINT16 OptType\r | |
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 | |
262 | UINT8 *\r | |
263 | Dhcp6SeekIaOption (\r | |
264 | IN UINT8 *Buf,\r | |
265 | IN UINT32 SeekLen,\r | |
266 | IN EFI_DHCP6_IA_DESCRIPTOR *IaDesc\r | |
267 | );\r | |
268 | \r | |
269 | /**\r | |
270 | Parse the address option and update the address info.\r | |
271 | \r | |
272 | @param[in] CurrentIa The pointer to the Ia Address in control block.\r | |
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 | |
279 | VOID\r | |
280 | Dhcp6ParseAddrOption (\r | |
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 | |
286 | );\r | |
287 | \r | |
288 | /**\r | |
289 | Create a control block for the Ia according to the corresponding options.\r | |
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 | |
300 | @retval EFI_DEVICE_ERROR An unexpected error.\r | |
301 | \r | |
302 | **/\r | |
303 | EFI_STATUS\r | |
304 | Dhcp6GenerateIaCb (\r | |
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 | |
310 | );\r | |
311 | \r | |
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 | |
321 | EFI_STATUS\r | |
322 | Dhcp6CacheIa (\r | |
323 | IN DHCP6_INSTANCE *Instance\r | |
324 | );\r | |
325 | \r | |
326 | /**\r | |
327 | Append CacheIa to the current IA. Meanwhile, clear CacheIa.ValidLifetime to 0.\r | |
328 | \r | |
329 | @param[in] Instance The pointer to DHCP6 instance.\r | |
330 | \r | |
331 | **/\r | |
332 | VOID\r | |
333 | Dhcp6AppendCacheIa (\r | |
334 | IN DHCP6_INSTANCE *Instance\r | |
335 | );\r | |
336 | \r | |
337 | /**\r | |
338 | Calculate the Dhcp6 get mapping timeout by adding additional delay to the IP6 DAD transmits count.\r | |
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 | |
346 | EFI_STATUS\r | |
347 | Dhcp6GetMappingTimeOut (\r | |
348 | IN EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg,\r | |
349 | OUT UINTN *TimeOut\r | |
350 | );\r | |
351 | \r | |
352 | #endif\r |