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__
13 #define DHCP6_10_BIT_MASK 0x3ff
14 #define DHCP6_DAD_ADDITIONAL_DELAY 30000000 // 3 seconds
17 Generate client Duid in the format of Duid-llt.
19 @param[in] Mode The pointer to the mode of SNP.
21 @retval NULL if failed to generate client Id.
22 @retval Others The pointer to the new client id.
26 Dhcp6GenerateClientId (
27 IN EFI_SIMPLE_NETWORK_MODE
*Mode
31 Copy the Dhcp6 configure data.
33 @param[in] DstCfg The pointer to the destination configure data.
34 @param[in] SorCfg The pointer to the source configure data.
36 @retval EFI_SUCCESS Copy the content from SorCfg from DstCfg successfully.
37 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
42 IN EFI_DHCP6_CONFIG_DATA
*DstCfg
,
43 IN EFI_DHCP6_CONFIG_DATA
*SorCfg
47 Clean up the configure data.
49 @param[in, out] CfgData The pointer to the configure data.
53 Dhcp6CleanupConfigData (
54 IN OUT EFI_DHCP6_CONFIG_DATA
*CfgData
58 Clean up the mode data.
60 @param[in, out] ModeData The pointer to the mode data.
64 Dhcp6CleanupModeData (
65 IN OUT EFI_DHCP6_MODE_DATA
*ModeData
69 Calculate the expire time by the algorithm defined in rfc.
71 @param[in] Base The base value of the time.
72 @param[in] IsFirstRt If TRUE, it is the first time to calculate expire time.
73 @param[in] NeedSigned If TRUE, the signed factor is needed.
75 @return Expire The calculated result for the new expire time.
79 Dhcp6CalculateExpireTime (
86 Calculate the lease time by the algorithm defined in rfc.
88 @param[in] IaCb The pointer to the Ia control block.
92 Dhcp6CalculateLeaseTime (
97 Check whether the addresses are all included by the configured Ia.
99 @param[in] Ia The pointer to the Ia.
100 @param[in] AddressCount The number of addresses.
101 @param[in] Addresses The pointer to the addresses buffer.
103 @retval EFI_SUCCESS The addresses are all included by the configured IA.
104 @retval EFI_NOT_FOUND The addresses are not included by the configured IA.
110 IN UINT32 AddressCount
,
111 IN EFI_IPv6_ADDRESS
*Addresses
115 Deprive the addresses from current Ia, and generate another eliminated Ia.
117 @param[in] Ia The pointer to the Ia.
118 @param[in] AddressCount The number of addresses.
119 @param[in] Addresses The pointer to the addresses buffer.
121 @retval NULL If failed to generate the deprived Ia.
122 @retval others The pointer to the deprived Ia.
126 Dhcp6DepriveAddress (
128 IN UINT32 AddressCount
,
129 IN EFI_IPv6_ADDRESS
*Addresses
133 The dummy ext buffer free callback routine.
135 @param[in] Arg The pointer to the parameter.
145 The callback routine once message transmitted.
147 @param[in] Wrap The pointer to the received net buffer.
148 @param[in] EndPoint The pointer to the udp end point.
149 @param[in] IoStatus The return status from udp io.
150 @param[in] Context The opaque parameter to the function.
157 IN UDP_END_POINT
*EndPoint
,
158 IN EFI_STATUS IoStatus
,
163 Append the appointed option to the buf, and move the buf to the end.
165 @param[in, out] Buf The pointer to buffer.
166 @param[in] OptType The option type.
167 @param[in] OptLen The length of option content.s
168 @param[in] Data The pointer to the option content.
170 @return Buf The position to append the next option.
182 Append the Ia option to Buf, and move Buf to the end.
184 @param[in, out] Buf The pointer to the position to append.
185 @param[in] Ia The pointer to the Ia.
186 @param[in] T1 The time of T1.
187 @param[in] T2 The time of T2.
188 @param[in] MessageType Message type of DHCP6 package.
190 @return Buf The position to append the next Ia option.
194 Dhcp6AppendIaOption (
199 IN UINT32 MessageType
203 Append the appointed Elapsed time option to Buf, and move Buf to the end.
205 @param[in, out] Buf The pointer to the position to append.
206 @param[in] Instance The pointer to the Dhcp6 instance.
207 @param[out] Elapsed The pointer to the elapsed time value in
208 the generated packet.
210 @return Buf The position to append the next Ia option.
214 Dhcp6AppendETOption (
216 IN DHCP6_INSTANCE
*Instance
,
221 Set the elapsed time based on the given instance and the pointer to the
224 @param[in] Elapsed The pointer to the position to append.
225 @param[in] Instance The pointer to the Dhcp6 instance.
230 IN DHCP6_INSTANCE
*Instance
234 Seek the address of the first byte of the option header.
236 @param[in] Buf The pointer to buffer.
237 @param[in] SeekLen The length to seek.
238 @param[in] OptType The option type.
240 @retval NULL If failed to seek the option.
241 @retval others The position to the option.
252 Seek the address of the first byte of the Ia option header.
254 @param[in] Buf The pointer to the buffer.
255 @param[in] SeekLen The length to seek.
256 @param[in] IaDesc The pointer to the Ia descriptor.
258 @retval NULL If failed to seek the Ia option.
259 @retval others The position to the Ia option.
266 IN EFI_DHCP6_IA_DESCRIPTOR
*IaDesc
270 Parse the address option and update the address info.
272 @param[in] CurrentIa The pointer to the Ia Address in control block.
273 @param[in] IaInnerOpt The pointer to the buffer.
274 @param[in] IaInnerLen The length to parse.
275 @param[out] AddrNum The number of addresses.
276 @param[in, out] AddrBuf The pointer to the address buffer.
280 Dhcp6ParseAddrOption (
281 IN EFI_DHCP6_IA
*CurrentIa
,
282 IN UINT8
*IaInnerOpt
,
283 IN UINT16 IaInnerLen
,
285 IN OUT EFI_DHCP6_IA_ADDRESS
*AddrBuf
289 Create a control block for the Ia according to the corresponding options.
291 @param[in] Instance The pointer to DHCP6 Instance.
292 @param[in] IaInnerOpt The pointer to the inner options in the Ia option.
293 @param[in] IaInnerLen The length of all the inner options in the Ia option.
294 @param[in] T1 T1 time in the Ia option.
295 @param[in] T2 T2 time in the Ia option.
297 @retval EFI_NOT_FOUND No valid IA option is found.
298 @retval EFI_SUCCESS Create an IA control block successfully.
299 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
300 @retval EFI_DEVICE_ERROR An unexpected error.
305 IN DHCP6_INSTANCE
*Instance
,
306 IN UINT8
*IaInnerOpt
,
307 IN UINT16 IaInnerLen
,
313 Cache the current IA configuration information.
315 @param[in] Instance The pointer to DHCP6 Instance.
317 @retval EFI_SUCCESS Cache the current IA successfully.
318 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
323 IN DHCP6_INSTANCE
*Instance
327 Append CacheIa to the current IA. Meanwhile, clear CacheIa.ValidLifetime to 0.
329 @param[in] Instance The pointer to DHCP6 instance.
334 IN DHCP6_INSTANCE
*Instance
338 Calculate the Dhcp6 get mapping timeout by adding additional delay to the IP6 DAD transmits count.
340 @param[in] Ip6Cfg The pointer to Ip6 config protocol.
341 @param[out] TimeOut The time out value in 100ns units.
343 @retval EFI_INVALID_PARAMETER Input parameters are invalid.
344 @retval EFI_SUCCESS Calculate the time out value successfully.
347 Dhcp6GetMappingTimeOut (
348 IN EFI_IP6_CONFIG_PROTOCOL
*Ip6Cfg
,