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