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