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