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