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