]> git.proxmox.com Git - mirror_edk2.git/blob - NetworkPkg/Ip6Dxe/Ip6ConfigImpl.h
NetworkPkg: Apply uncrustify changes
[mirror_edk2.git] / NetworkPkg / Ip6Dxe / Ip6ConfigImpl.h
1 /** @file
2 Definitions for EFI IPv6 Configuration Protocol implementation.
3
4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #ifndef __IP6_CONFIG_IMPL_H__
11 #define __IP6_CONFIG_IMPL_H__
12
13 #define IP6_CONFIG_INSTANCE_SIGNATURE SIGNATURE_32 ('I', 'P', '6', 'C')
14 #define IP6_FORM_CALLBACK_INFO_SIGNATURE SIGNATURE_32 ('I', 'F', 'C', 'I')
15 #define IP6_CONFIG_VARIABLE_ATTRIBUTE (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS)
16
17 #define IP6_CONFIG_DEFAULT_DAD_XMITS 1
18
19 #define DATA_ATTRIB_SIZE_FIXED 0x1
20 #define DATA_ATTRIB_VOLATILE 0x2
21
22 #define DATA_ATTRIB_SET(Attrib, Bits) (BOOLEAN)((Attrib) & (Bits))
23 #define SET_DATA_ATTRIB(Attrib, Bits) ((Attrib) |= (Bits))
24
25 typedef struct _IP6_CONFIG_INSTANCE IP6_CONFIG_INSTANCE;
26
27 #define IP6_CONFIG_INSTANCE_FROM_PROTOCOL(Proto) \
28 CR ((Proto), \
29 IP6_CONFIG_INSTANCE, \
30 Ip6Config, \
31 IP6_CONFIG_INSTANCE_SIGNATURE \
32 )
33
34 #define IP6_CONFIG_INSTANCE_FROM_FORM_CALLBACK(Callback) \
35 CR ((Callback), \
36 IP6_CONFIG_INSTANCE, \
37 CallbackInfo, \
38 IP6_CONFIG_INSTANCE_SIGNATURE \
39 )
40
41 #define IP6_SERVICE_FROM_IP6_CONFIG_INSTANCE(Instance) \
42 CR ((Instance), \
43 IP6_SERVICE, \
44 Ip6ConfigInstance, \
45 IP6_SERVICE_SIGNATURE \
46 )
47
48 #define IP6_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS(ConfigAccess) \
49 CR ((ConfigAccess), \
50 IP6_FORM_CALLBACK_INFO, \
51 HiiConfigAccess, \
52 IP6_FORM_CALLBACK_INFO_SIGNATURE \
53 )
54
55 /**
56 The prototype of work function for EfiIp6ConfigSetData().
57
58 @param[in] Instance The pointer to the IP6 config instance data.
59 @param[in] DataSize In bytes, the size of the buffer pointed to by Data.
60 @param[in] Data The data buffer to set.
61
62 @retval EFI_BAD_BUFFER_SIZE The DataSize does not match the size of the type,
63 8 bytes.
64 @retval EFI_SUCCESS The specified configuration data for the EFI IPv6
65 network stack was set successfully.
66
67 **/
68 typedef
69 EFI_STATUS
70 (*IP6_CONFIG_SET_DATA) (
71 IN IP6_CONFIG_INSTANCE *Instance,
72 IN UINTN DataSize,
73 IN VOID *Data
74 );
75
76 /**
77 The prototype of work function for EfiIp6ConfigGetData().
78
79 @param[in] Instance The pointer to the IP6 config instance data.
80 @param[in, out] DataSize On input, in bytes, the size of Data. On output, in
81 bytes, the size of buffer required to store the specified
82 configuration data.
83 @param[in] Data The data buffer in which the configuration data is returned.
84 Ignored if DataSize is ZERO.
85
86 @retval EFI_BUFFER_TOO_SMALL The size of Data is too small for the specified
87 configuration data, and the required size is
88 returned in DataSize.
89 @retval EFI_SUCCESS The specified configuration data was obtained successfully.
90
91 **/
92 typedef
93 EFI_STATUS
94 (*IP6_CONFIG_GET_DATA) (
95 IN IP6_CONFIG_INSTANCE *Instance,
96 IN OUT UINTN *DataSize,
97 IN VOID *Data OPTIONAL
98 );
99
100 typedef union {
101 VOID *Ptr;
102 EFI_IP6_CONFIG_INTERFACE_INFO *IfInfo;
103 EFI_IP6_CONFIG_INTERFACE_ID *AltIfId;
104 EFI_IP6_CONFIG_POLICY *Policy;
105 EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS *DadXmits;
106 EFI_IP6_CONFIG_MANUAL_ADDRESS *ManualAddress;
107 EFI_IPv6_ADDRESS *Gateway;
108 EFI_IPv6_ADDRESS *DnsServers;
109 } IP6_CONFIG_DATA;
110
111 typedef struct {
112 IP6_CONFIG_SET_DATA SetData;
113 IP6_CONFIG_GET_DATA GetData;
114 EFI_STATUS Status;
115 UINT8 Attribute;
116 NET_MAP EventMap;
117 IP6_CONFIG_DATA Data;
118 UINTN DataSize;
119 } IP6_CONFIG_DATA_ITEM;
120
121 typedef struct {
122 UINT16 Offset;
123 UINT32 DataSize;
124 EFI_IP6_CONFIG_DATA_TYPE DataType;
125 } IP6_CONFIG_DATA_RECORD;
126
127 #pragma pack(1)
128
129 //
130 // heap data that contains the data for each data record.
131 //
132 // BOOLEAN IsAltIfIdSet;
133 // EFI_IP6_CONFIG_POLICY Policy;
134 // EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS DadXmits;
135 // UINT32 ManualaddressCount;
136 // UINT32 GatewayCount;
137 // UINT32 DnsServersCount;
138 // EFI_IP6_CONFIG_INTERFACE_ID AltIfId;
139 // EFI_IP6_CONFIG_MANUAL_ADDRESS ManualAddress[];
140 // EFI_IPv6_ADDRESS Gateway[];
141 // EFI_IPv6_ADDRESS DnsServers[];
142 //
143 typedef struct {
144 UINT32 IaId;
145 UINT16 Checksum;
146 UINT16 DataRecordCount;
147 IP6_CONFIG_DATA_RECORD DataRecord[1];
148 } IP6_CONFIG_VARIABLE;
149
150 #pragma pack()
151
152 typedef struct {
153 LIST_ENTRY Link;
154 EFI_IP6_ADDRESS_INFO AddrInfo;
155 } IP6_ADDRESS_INFO_ENTRY;
156
157 typedef struct {
158 EFI_IP6_CONFIG_POLICY Policy; ///< manual or automatic
159 EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS DadTransmitCount; ///< dad transmits count
160 EFI_IP6_CONFIG_INTERFACE_ID InterfaceId; ///< alternative interface id
161 LIST_ENTRY ManualAddress; ///< IP addresses
162 UINT32 ManualAddressCount; ///< IP addresses count
163 LIST_ENTRY GatewayAddress; ///< Gateway address
164 UINT32 GatewayAddressCount; ///< Gateway address count
165 LIST_ENTRY DnsAddress; ///< DNS server address
166 UINT32 DnsAddressCount; ///< DNS server address count
167 } IP6_CONFIG_NVDATA;
168
169 typedef struct _IP6_FORM_CALLBACK_INFO {
170 UINT32 Signature;
171 EFI_HANDLE ChildHandle;
172 EFI_HII_CONFIG_ACCESS_PROTOCOL HiiConfigAccess;
173 EFI_DEVICE_PATH_PROTOCOL *HiiVendorDevicePath;
174 EFI_HII_HANDLE RegisteredHandle;
175 } IP6_FORM_CALLBACK_INFO;
176
177 struct _IP6_CONFIG_INSTANCE {
178 UINT32 Signature;
179 BOOLEAN Configured;
180 LIST_ENTRY Link;
181 UINT16 IfIndex;
182
183 EFI_IP6_CONFIG_INTERFACE_INFO InterfaceInfo;
184 EFI_IP6_CONFIG_INTERFACE_ID AltIfId;
185 EFI_IP6_CONFIG_POLICY Policy;
186 EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS DadXmits;
187
188 IP6_CONFIG_DATA_ITEM DataItem[Ip6ConfigDataTypeMaximum];
189 NET_MAP DadFailedMap;
190 NET_MAP DadPassedMap;
191
192 EFI_IP6_CONFIG_PROTOCOL Ip6Config;
193
194 EFI_EVENT Dhcp6SbNotifyEvent;
195 VOID *Registration;
196 EFI_HANDLE Dhcp6Handle;
197 EFI_DHCP6_PROTOCOL *Dhcp6;
198 BOOLEAN OtherInfoOnly;
199 UINT32 IaId;
200 EFI_EVENT Dhcp6Event;
201 UINT32 FailedIaAddressCount;
202 EFI_IPv6_ADDRESS *DeclineAddress;
203 UINT32 DeclineAddressCount;
204
205 IP6_FORM_CALLBACK_INFO CallbackInfo;
206 IP6_CONFIG_NVDATA Ip6NvData;
207 };
208
209 /**
210 Read the configuration data from variable storage according to the VarName and
211 gEfiIp6ConfigProtocolGuid. It checks the integrity of variable data. If the
212 data is corrupted, it clears the variable data to ZERO. Otherwise, it outputs the
213 configuration data to IP6_CONFIG_INSTANCE.
214
215 @param[in] VarName The pointer to the variable name
216 @param[in, out] Instance The pointer to the IP6 config instance data.
217
218 @retval EFI_NOT_FOUND The variable can not be found or already corrupted.
219 @retval EFI_OUT_OF_RESOURCES Fail to allocate resource to complete the operation.
220 @retval EFI_SUCCESS The configuration data was retrieved successfully.
221
222 **/
223 EFI_STATUS
224 Ip6ConfigReadConfigData (
225 IN CHAR16 *VarName,
226 IN OUT IP6_CONFIG_INSTANCE *Instance
227 );
228
229 /**
230 The event process routine when the DHCPv6 server is answered with a reply packet
231 for an information request.
232
233 @param[in] This Points to the EFI_DHCP6_PROTOCOL.
234 @param[in] Context The pointer to the IP6 configuration instance data.
235 @param[in] Packet The DHCPv6 reply packet.
236
237 @retval EFI_SUCCESS The DNS server address was retrieved from the reply packet.
238 @retval EFI_NOT_READY The reply packet does not contain the DNS server option, or
239 the DNS server address is not valid.
240
241 **/
242 EFI_STATUS
243 EFIAPI
244 Ip6ConfigOnDhcp6Reply (
245 IN EFI_DHCP6_PROTOCOL *This,
246 IN VOID *Context,
247 IN EFI_DHCP6_PACKET *Packet
248 );
249
250 /**
251 The work function to trigger the DHCPv6 process to perform a stateful autoconfiguration.
252
253 @param[in] Instance Pointer to the IP6 config instance data.
254 @param[in] OtherInfoOnly If FALSE, get stateful address and other information
255 via DHCPv6. Otherwise, only get the other information.
256
257 @retval EFI_SUCCESS The operation finished successfully.
258 @retval EFI_UNSUPPORTED The DHCP6 driver is not available.
259
260 **/
261 EFI_STATUS
262 Ip6ConfigStartStatefulAutoConfig (
263 IN IP6_CONFIG_INSTANCE *Instance,
264 IN BOOLEAN OtherInfoOnly
265 );
266
267 /**
268 Initialize an IP6_CONFIG_INSTANCE.
269
270 @param[out] Instance The buffer of IP6_CONFIG_INSTANCE to be initialized.
271
272 @retval EFI_OUT_OF_RESOURCES Failed to allocate resources to complete the operation.
273 @retval EFI_SUCCESS The IP6_CONFIG_INSTANCE initialized successfully.
274
275 **/
276 EFI_STATUS
277 Ip6ConfigInitInstance (
278 OUT IP6_CONFIG_INSTANCE *Instance
279 );
280
281 /**
282 Release an IP6_CONFIG_INSTANCE.
283
284 @param[in, out] Instance The buffer of IP6_CONFIG_INSTANCE to be freed.
285
286 **/
287 VOID
288 Ip6ConfigCleanInstance (
289 IN OUT IP6_CONFIG_INSTANCE *Instance
290 );
291
292 /**
293 Destroy the Dhcp6 child in IP6_CONFIG_INSTANCE and release the resources.
294
295 @param[in, out] Instance The buffer of IP6_CONFIG_INSTANCE to be freed.
296
297 @retval EFI_SUCCESS The child was successfully destroyed.
298 @retval Others Failed to destroy the child.
299
300 **/
301 EFI_STATUS
302 Ip6ConfigDestroyDhcp6 (
303 IN OUT IP6_CONFIG_INSTANCE *Instance
304 );
305
306 #endif