]>
Commit | Line | Data |
---|---|---|
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 | |
32 | EFI_DHCP6_DUID *\r | |
33 | Dhcp6GenerateClientId (\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 | |
47 | EFI_STATUS\r | |
48 | Dhcp6CopyConfigData (\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 | |
59 | VOID\r | |
60 | Dhcp6CleanupConfigData (\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 | |
70 | VOID\r | |
71 | Dhcp6CleanupModeData (\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 | |
85 | UINT32\r | |
86 | Dhcp6CalculateExpireTime (\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 | |
98 | VOID\r | |
99 | Dhcp6CalculateLeaseTime (\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 | |
114 | EFI_STATUS\r | |
115 | Dhcp6CheckAddress (\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 | |
132 | EFI_DHCP6_IA *\r | |
133 | Dhcp6DepriveAddress (\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 | |
145 | VOID\r | |
146 | EFIAPI\r | |
147 | Dhcp6DummyExtFree (\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 | |
160 | VOID\r | |
161 | EFIAPI\r | |
162 | Dhcp6OnTransmitted (\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 | |
180 | UINT8 *\r | |
181 | Dhcp6AppendOption (\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 | |
685e44a5 | 195 | @param[in] MessageType Message type of DHCP6 package.\r |
a3bcde70 HT |
196 | \r |
197 | @return Buf The position to append the next Ia option.\r | |
198 | \r | |
199 | **/\r | |
200 | UINT8 *\r | |
201 | Dhcp6AppendIaOption (\r | |
202 | IN OUT UINT8 *Buf,\r | |
203 | IN EFI_DHCP6_IA *Ia,\r | |
204 | IN UINT32 T1,\r | |
685e44a5 | 205 | IN UINT32 T2,\r |
206 | IN UINT32 MessageType\r | |
a3bcde70 HT |
207 | );\r |
208 | \r | |
209 | /**\r | |
210 | Append the appointed Elapsed time option to Buf, and move Buf to the end.\r | |
211 | \r | |
212 | @param[in, out] Buf The pointer to the position to append.\r | |
213 | @param[in] Instance The pointer to the Dhcp6 instance.\r | |
214 | @param[out] Elapsed The pointer to the elapsed time value in\r | |
215 | the generated packet.\r | |
216 | \r | |
217 | @return Buf The position to append the next Ia option.\r | |
218 | \r | |
219 | **/\r | |
220 | UINT8 *\r | |
221 | Dhcp6AppendETOption (\r | |
222 | IN OUT UINT8 *Buf,\r | |
223 | IN DHCP6_INSTANCE *Instance,\r | |
224 | OUT UINT16 **Elapsed\r | |
225 | );\r | |
226 | \r | |
227 | /**\r | |
228 | Set the elapsed time based on the given instance and the pointer to the\r | |
229 | elapsed time option.\r | |
230 | \r | |
231 | @param[in] Elapsed The pointer to the position to append.\r | |
232 | @param[in] Instance The pointer to the Dhcp6 instance.\r | |
233 | **/\r | |
234 | VOID\r | |
235 | SetElapsedTime (\r | |
236 | IN UINT16 *Elapsed,\r | |
237 | IN DHCP6_INSTANCE *Instance\r | |
238 | );\r | |
239 | \r | |
240 | /**\r | |
241 | Seek the address of the first byte of the option header.\r | |
242 | \r | |
243 | @param[in] Buf The pointer to buffer.\r | |
244 | @param[in] SeekLen The length to seek.\r | |
245 | @param[in] OptType The option type.\r | |
246 | \r | |
247 | @retval NULL If failed to seek the option.\r | |
248 | @retval others The position to the option.\r | |
249 | \r | |
250 | **/\r | |
251 | UINT8 *\r | |
252 | Dhcp6SeekOption (\r | |
253 | IN UINT8 *Buf,\r | |
254 | IN UINT32 SeekLen,\r | |
255 | IN UINT16 OptType\r | |
256 | );\r | |
257 | \r | |
258 | /**\r | |
259 | Seek the address of the first byte of the Ia option header.\r | |
260 | \r | |
261 | @param[in] Buf The pointer to the buffer.\r | |
262 | @param[in] SeekLen The length to seek.\r | |
263 | @param[in] IaDesc The pointer to the Ia descriptor.\r | |
264 | \r | |
265 | @retval NULL If failed to seek the Ia option.\r | |
266 | @retval others The position to the Ia option.\r | |
267 | \r | |
268 | **/\r | |
269 | UINT8 *\r | |
270 | Dhcp6SeekIaOption (\r | |
271 | IN UINT8 *Buf,\r | |
272 | IN UINT32 SeekLen,\r | |
273 | IN EFI_DHCP6_IA_DESCRIPTOR *IaDesc\r | |
274 | );\r | |
275 | \r | |
276 | /**\r | |
277 | Parse the address option and update the address info.\r | |
278 | \r | |
685e44a5 | 279 | @param[in] CurrentIa The pointer to the Ia Address in control blcok.\r |
a3bcde70 HT |
280 | @param[in] IaInnerOpt The pointer to the buffer.\r |
281 | @param[in] IaInnerLen The length to parse.\r | |
282 | @param[out] AddrNum The number of addresses.\r | |
283 | @param[in, out] AddrBuf The pointer to the address buffer.\r | |
284 | \r | |
285 | **/\r | |
286 | VOID\r | |
287 | Dhcp6ParseAddrOption (\r | |
685e44a5 | 288 | IN EFI_DHCP6_IA *CurrentIa,\r |
a3bcde70 HT |
289 | IN UINT8 *IaInnerOpt,\r |
290 | IN UINT16 IaInnerLen,\r | |
291 | OUT UINT32 *AddrNum,\r | |
292 | IN OUT EFI_DHCP6_IA_ADDRESS *AddrBuf\r | |
293 | );\r | |
294 | \r | |
295 | /**\r | |
296 | Create a control blcok for the Ia according to the corresponding options.\r | |
297 | \r | |
298 | @param[in] Instance The pointer to DHCP6 Instance.\r | |
299 | @param[in] IaInnerOpt The pointer to the inner options in the Ia option.\r | |
300 | @param[in] IaInnerLen The length of all the inner options in the Ia option.\r | |
301 | @param[in] T1 T1 time in the Ia option.\r | |
302 | @param[in] T2 T2 time in the Ia option.\r | |
303 | \r | |
304 | @retval EFI_NOT_FOUND No valid IA option is found.\r | |
305 | @retval EFI_SUCCESS Create an IA control block successfully.\r | |
306 | @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r | |
685e44a5 | 307 | @retval EFI_DEVICE_ERROR An unexpected error.\r |
a3bcde70 HT |
308 | \r |
309 | **/\r | |
310 | EFI_STATUS\r | |
311 | Dhcp6GenerateIaCb (\r | |
312 | IN DHCP6_INSTANCE *Instance,\r | |
313 | IN UINT8 *IaInnerOpt,\r | |
314 | IN UINT16 IaInnerLen,\r | |
315 | IN UINT32 T1,\r | |
316 | IN UINT32 T2\r | |
317 | );\r | |
318 | \r | |
319 | \r | |
320 | /**\r | |
321 | Cache the current IA configuration information.\r | |
322 | \r | |
323 | @param[in] Instance The pointer to DHCP6 Instance.\r | |
324 | \r | |
325 | @retval EFI_SUCCESS Cache the current IA successfully.\r | |
326 | @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r | |
327 | \r | |
328 | **/\r | |
329 | EFI_STATUS\r | |
330 | Dhcp6CacheIa (\r | |
331 | IN DHCP6_INSTANCE *Instance\r | |
332 | );\r | |
333 | \r | |
334 | \r | |
335 | /**\r | |
336 | Append CacheIa to the currrent IA. Meanwhile, clear CacheIa.ValidLifetime to 0.\r | |
337 | \r | |
338 | @param[in] Instance The pointer to DHCP6 instance.\r | |
339 | \r | |
340 | **/\r | |
341 | VOID\r | |
342 | Dhcp6AppendCacheIa (\r | |
343 | IN DHCP6_INSTANCE *Instance\r | |
344 | );\r | |
345 | \r | |
cc658224 | 346 | /**\r |
347 | Calculate the Dhcp6 get mapping timeout by adding additinal delay to the IP6 DAD transmits count.\r | |
348 | \r | |
349 | @param[in] Ip6Cfg The pointer to Ip6 config protocol.\r | |
350 | @param[out] TimeOut The time out value in 100ns units.\r | |
351 | \r | |
352 | @retval EFI_INVALID_PARAMETER Input parameters are invalid.\r | |
353 | @retval EFI_SUCCESS Calculate the time out value successfully.\r | |
354 | **/\r | |
355 | EFI_STATUS\r | |
356 | Dhcp6GetMappingTimeOut (\r | |
357 | IN EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg,\r | |
358 | OUT UINTN *TimeOut\r | |
359 | );\r | |
a3bcde70 | 360 | #endif\r |