2 Dhcp6 support functions declaration.
4 Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
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.
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.
16 #ifndef __EFI_DHCP6_UTILITY_H__
17 #define __EFI_DHCP6_UTILITY_H__
20 #define DHCP6_10_BIT_MASK 0x3ff
21 #define DHCP6_DAD_ADDITIONAL_DELAY 30000000 // 3 seconds
24 Generate client Duid in the format of Duid-llt.
26 @param[in] Mode The pointer to the mode of SNP.
28 @retval NULL if failed to generate client Id.
29 @retval Others The pointer to the new client id.
33 Dhcp6GenerateClientId (
34 IN EFI_SIMPLE_NETWORK_MODE
*Mode
38 Copy the Dhcp6 configure data.
40 @param[in] DstCfg The pointer to the destination configure data.
41 @param[in] SorCfg The pointer to the source configure data.
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.
49 IN EFI_DHCP6_CONFIG_DATA
*DstCfg
,
50 IN EFI_DHCP6_CONFIG_DATA
*SorCfg
54 Clean up the configure data.
56 @param[in, out] CfgData The pointer to the configure data.
60 Dhcp6CleanupConfigData (
61 IN OUT EFI_DHCP6_CONFIG_DATA
*CfgData
65 Clean up the mode data.
67 @param[in, out] ModeData The pointer to the mode data.
71 Dhcp6CleanupModeData (
72 IN OUT EFI_DHCP6_MODE_DATA
*ModeData
76 Calculate the expire time by the algorithm defined in rfc.
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.
82 @return Expire The calculated result for the new expire time.
86 Dhcp6CalculateExpireTime (
93 Calculate the lease time by the algorithm defined in rfc.
95 @param[in] IaCb The pointer to the Ia control block.
99 Dhcp6CalculateLeaseTime (
104 Check whether the addresses are all included by the configured Ia.
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.
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.
117 IN UINT32 AddressCount
,
118 IN EFI_IPv6_ADDRESS
*Addresses
122 Deprive the addresses from current Ia, and generate another eliminated Ia.
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.
128 @retval NULL If failed to generate the deprived Ia.
129 @retval others The pointer to the deprived Ia.
133 Dhcp6DepriveAddress (
135 IN UINT32 AddressCount
,
136 IN EFI_IPv6_ADDRESS
*Addresses
140 The dummy ext buffer free callback routine.
142 @param[in] Arg The pointer to the parameter.
152 The callback routine once message transmitted.
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.
164 IN UDP_END_POINT
*EndPoint
,
165 IN EFI_STATUS IoStatus
,
170 Append the appointed option to the buf, and move the buf to the end.
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.
177 @return Buf The position to append the next option.
189 Append the Ia option to Buf, and move Buf to the end.
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 @param[in] MessageType Message type of DHCP6 package.
197 @return Buf The position to append the next Ia option.
201 Dhcp6AppendIaOption (
206 IN UINT32 MessageType
210 Append the appointed Elapsed time option to Buf, and move Buf to the end.
212 @param[in, out] Buf The pointer to the position to append.
213 @param[in] Instance The pointer to the Dhcp6 instance.
214 @param[out] Elapsed The pointer to the elapsed time value in
215 the generated packet.
217 @return Buf The position to append the next Ia option.
221 Dhcp6AppendETOption (
223 IN DHCP6_INSTANCE
*Instance
,
228 Set the elapsed time based on the given instance and the pointer to the
231 @param[in] Elapsed The pointer to the position to append.
232 @param[in] Instance The pointer to the Dhcp6 instance.
237 IN DHCP6_INSTANCE
*Instance
241 Seek the address of the first byte of the option header.
243 @param[in] Buf The pointer to buffer.
244 @param[in] SeekLen The length to seek.
245 @param[in] OptType The option type.
247 @retval NULL If failed to seek the option.
248 @retval others The position to the option.
259 Seek the address of the first byte of the Ia option header.
261 @param[in] Buf The pointer to the buffer.
262 @param[in] SeekLen The length to seek.
263 @param[in] IaDesc The pointer to the Ia descriptor.
265 @retval NULL If failed to seek the Ia option.
266 @retval others The position to the Ia option.
273 IN EFI_DHCP6_IA_DESCRIPTOR
*IaDesc
277 Parse the address option and update the address info.
279 @param[in] CurrentIa The pointer to the Ia Address in control blcok.
280 @param[in] IaInnerOpt The pointer to the buffer.
281 @param[in] IaInnerLen The length to parse.
282 @param[out] AddrNum The number of addresses.
283 @param[in, out] AddrBuf The pointer to the address buffer.
287 Dhcp6ParseAddrOption (
288 IN EFI_DHCP6_IA
*CurrentIa
,
289 IN UINT8
*IaInnerOpt
,
290 IN UINT16 IaInnerLen
,
292 IN OUT EFI_DHCP6_IA_ADDRESS
*AddrBuf
296 Create a control blcok for the Ia according to the corresponding options.
298 @param[in] Instance The pointer to DHCP6 Instance.
299 @param[in] IaInnerOpt The pointer to the inner options in the Ia option.
300 @param[in] IaInnerLen The length of all the inner options in the Ia option.
301 @param[in] T1 T1 time in the Ia option.
302 @param[in] T2 T2 time in the Ia option.
304 @retval EFI_NOT_FOUND No valid IA option is found.
305 @retval EFI_SUCCESS Create an IA control block successfully.
306 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
307 @retval EFI_DEVICE_ERROR An unexpected error.
312 IN DHCP6_INSTANCE
*Instance
,
313 IN UINT8
*IaInnerOpt
,
314 IN UINT16 IaInnerLen
,
321 Cache the current IA configuration information.
323 @param[in] Instance The pointer to DHCP6 Instance.
325 @retval EFI_SUCCESS Cache the current IA successfully.
326 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
331 IN DHCP6_INSTANCE
*Instance
336 Append CacheIa to the currrent IA. Meanwhile, clear CacheIa.ValidLifetime to 0.
338 @param[in] Instance The pointer to DHCP6 instance.
343 IN DHCP6_INSTANCE
*Instance
347 Calculate the Dhcp6 get mapping timeout by adding additinal delay to the IP6 DAD transmits count.
349 @param[in] Ip6Cfg The pointer to Ip6 config protocol.
350 @param[out] TimeOut The time out value in 100ns units.
352 @retval EFI_INVALID_PARAMETER Input parameters are invalid.
353 @retval EFI_SUCCESS Calculate the time out value successfully.
356 Dhcp6GetMappingTimeOut (
357 IN EFI_IP6_CONFIG_PROTOCOL
*Ip6Cfg
,