2 Dhcp6 support functions declaration.
4 Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #ifndef __EFI_DHCP6_UTILITY_H__
11 #define __EFI_DHCP6_UTILITY_H__
14 #define DHCP6_10_BIT_MASK 0x3ff
15 #define DHCP6_DAD_ADDITIONAL_DELAY 30000000 // 3 seconds
18 Generate client Duid in the format of Duid-llt.
20 @param[in] Mode The pointer to the mode of SNP.
22 @retval NULL if failed to generate client Id.
23 @retval Others The pointer to the new client id.
27 Dhcp6GenerateClientId (
28 IN EFI_SIMPLE_NETWORK_MODE
*Mode
32 Copy the Dhcp6 configure data.
34 @param[in] DstCfg The pointer to the destination configure data.
35 @param[in] SorCfg The pointer to the source configure data.
37 @retval EFI_SUCCESS Copy the content from SorCfg from DstCfg successfully.
38 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
43 IN EFI_DHCP6_CONFIG_DATA
*DstCfg
,
44 IN EFI_DHCP6_CONFIG_DATA
*SorCfg
48 Clean up the configure data.
50 @param[in, out] CfgData The pointer to the configure data.
54 Dhcp6CleanupConfigData (
55 IN OUT EFI_DHCP6_CONFIG_DATA
*CfgData
59 Clean up the mode data.
61 @param[in, out] ModeData The pointer to the mode data.
65 Dhcp6CleanupModeData (
66 IN OUT EFI_DHCP6_MODE_DATA
*ModeData
70 Calculate the expire time by the algorithm defined in rfc.
72 @param[in] Base The base value of the time.
73 @param[in] IsFirstRt If TRUE, it is the first time to calculate expire time.
74 @param[in] NeedSigned If TRUE, the the signed factor is needed.
76 @return Expire The calculated result for the new expire time.
80 Dhcp6CalculateExpireTime (
87 Calculate the lease time by the algorithm defined in rfc.
89 @param[in] IaCb The pointer to the Ia control block.
93 Dhcp6CalculateLeaseTime (
98 Check whether the addresses are all included by the configured Ia.
100 @param[in] Ia The pointer to the Ia.
101 @param[in] AddressCount The number of addresses.
102 @param[in] Addresses The pointer to the addresses buffer.
104 @retval EFI_SUCCESS The addresses are all included by the configured IA.
105 @retval EFI_NOT_FOUND The addresses are not included by the configured IA.
111 IN UINT32 AddressCount
,
112 IN EFI_IPv6_ADDRESS
*Addresses
116 Deprive the addresses from current Ia, and generate another eliminated Ia.
118 @param[in] Ia The pointer to the Ia.
119 @param[in] AddressCount The number of addresses.
120 @param[in] Addresses The pointer to the addresses buffer.
122 @retval NULL If failed to generate the deprived Ia.
123 @retval others The pointer to the deprived Ia.
127 Dhcp6DepriveAddress (
129 IN UINT32 AddressCount
,
130 IN EFI_IPv6_ADDRESS
*Addresses
134 The dummy ext buffer free callback routine.
136 @param[in] Arg The pointer to the parameter.
146 The callback routine once message transmitted.
148 @param[in] Wrap The pointer to the received net buffer.
149 @param[in] EndPoint The pointer to the udp end point.
150 @param[in] IoStatus The return status from udp io.
151 @param[in] Context The opaque parameter to the function.
158 IN UDP_END_POINT
*EndPoint
,
159 IN EFI_STATUS IoStatus
,
164 Append the appointed option to the buf, and move the buf to the end.
166 @param[in, out] Buf The pointer to buffer.
167 @param[in] OptType The option type.
168 @param[in] OptLen The lenght of option content.s
169 @param[in] Data The pointer to the option content.
171 @return Buf The position to append the next option.
183 Append the Ia option to Buf, and move Buf to the end.
185 @param[in, out] Buf The pointer to the position to append.
186 @param[in] Ia The pointer to the Ia.
187 @param[in] T1 The time of T1.
188 @param[in] T2 The time of T2.
189 @param[in] MessageType Message type of DHCP6 package.
191 @return Buf The position to append the next Ia option.
195 Dhcp6AppendIaOption (
200 IN UINT32 MessageType
204 Append the appointed Elapsed time option to Buf, and move Buf to the end.
206 @param[in, out] Buf The pointer to the position to append.
207 @param[in] Instance The pointer to the Dhcp6 instance.
208 @param[out] Elapsed The pointer to the elapsed time value in
209 the generated packet.
211 @return Buf The position to append the next Ia option.
215 Dhcp6AppendETOption (
217 IN DHCP6_INSTANCE
*Instance
,
222 Set the elapsed time based on the given instance and the pointer to the
225 @param[in] Elapsed The pointer to the position to append.
226 @param[in] Instance The pointer to the Dhcp6 instance.
231 IN DHCP6_INSTANCE
*Instance
235 Seek the address of the first byte of the option header.
237 @param[in] Buf The pointer to buffer.
238 @param[in] SeekLen The length to seek.
239 @param[in] OptType The option type.
241 @retval NULL If failed to seek the option.
242 @retval others The position to the option.
253 Seek the address of the first byte of the Ia option header.
255 @param[in] Buf The pointer to the buffer.
256 @param[in] SeekLen The length to seek.
257 @param[in] IaDesc The pointer to the Ia descriptor.
259 @retval NULL If failed to seek the Ia option.
260 @retval others The position to the Ia option.
267 IN EFI_DHCP6_IA_DESCRIPTOR
*IaDesc
271 Parse the address option and update the address info.
273 @param[in] CurrentIa The pointer to the Ia Address in control blcok.
274 @param[in] IaInnerOpt The pointer to the buffer.
275 @param[in] IaInnerLen The length to parse.
276 @param[out] AddrNum The number of addresses.
277 @param[in, out] AddrBuf The pointer to the address buffer.
281 Dhcp6ParseAddrOption (
282 IN EFI_DHCP6_IA
*CurrentIa
,
283 IN UINT8
*IaInnerOpt
,
284 IN UINT16 IaInnerLen
,
286 IN OUT EFI_DHCP6_IA_ADDRESS
*AddrBuf
290 Create a control blcok for the Ia according to the corresponding options.
292 @param[in] Instance The pointer to DHCP6 Instance.
293 @param[in] IaInnerOpt The pointer to the inner options in the Ia option.
294 @param[in] IaInnerLen The length of all the inner options in the Ia option.
295 @param[in] T1 T1 time in the Ia option.
296 @param[in] T2 T2 time in the Ia option.
298 @retval EFI_NOT_FOUND No valid IA option is found.
299 @retval EFI_SUCCESS Create an IA control block successfully.
300 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
301 @retval EFI_DEVICE_ERROR An unexpected error.
306 IN DHCP6_INSTANCE
*Instance
,
307 IN UINT8
*IaInnerOpt
,
308 IN UINT16 IaInnerLen
,
315 Cache the current IA configuration information.
317 @param[in] Instance The pointer to DHCP6 Instance.
319 @retval EFI_SUCCESS Cache the current IA successfully.
320 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
325 IN DHCP6_INSTANCE
*Instance
330 Append CacheIa to the currrent IA. Meanwhile, clear CacheIa.ValidLifetime to 0.
332 @param[in] Instance The pointer to DHCP6 instance.
337 IN DHCP6_INSTANCE
*Instance
341 Calculate the Dhcp6 get mapping timeout by adding additinal delay to the IP6 DAD transmits count.
343 @param[in] Ip6Cfg The pointer to Ip6 config protocol.
344 @param[out] TimeOut The time out value in 100ns units.
346 @retval EFI_INVALID_PARAMETER Input parameters are invalid.
347 @retval EFI_SUCCESS Calculate the time out value successfully.
350 Dhcp6GetMappingTimeOut (
351 IN EFI_IP6_CONFIG_PROTOCOL
*Ip6Cfg
,