]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.h
MdeModulePkg: Change the default IPv4 config policy
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4Dxe / Ip4Config2Impl.h
CommitLineData
1f6729ff 1/** @file\r
2 Definitions for EFI IPv4 Configuration II Protocol implementation.\r
3\r
7648748e 4 Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
9feefde0 5 (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
1f6729ff 6\r
7 This program and the accompanying materials\r
8 are licensed and made available under the terms and conditions of the BSD License\r
9 which accompanies this distribution. The full text of the license may be found at\r
10 http://opensource.org/licenses/bsd-license.php.\r
11\r
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15**/\r
16\r
17#ifndef __IP4_CONFIG2_IMPL_H__\r
18#define __IP4_CONFIG2_IMPL_H__\r
19\r
20#define IP4_CONFIG2_INSTANCE_SIGNATURE SIGNATURE_32 ('I', 'P', 'C', '2')\r
21#define IP4_FORM_CALLBACK_INFO_SIGNATURE SIGNATURE_32 ('I', 'F', 'C', 'I')\r
22\r
23#define IP4_CONFIG2_VARIABLE_ATTRIBUTE (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS)\r
24\r
25#define DATA_ATTRIB_SIZE_FIXED 0x1\r
26#define DATA_ATTRIB_VOLATILE 0x2\r
27\r
28#define DHCP_TAG_PARA_LIST 55\r
29#define DHCP_TAG_NETMASK 1\r
30#define DHCP_TAG_ROUTER 3\r
9feefde0 31#define DHCP_TAG_DNS_SERVER 6\r
1f6729ff 32\r
33#define DATA_ATTRIB_SET(Attrib, Bits) (BOOLEAN)((Attrib) & (Bits))\r
34#define SET_DATA_ATTRIB(Attrib, Bits) ((Attrib) |= (Bits))\r
35\r
36typedef struct _IP4_CONFIG2_INSTANCE IP4_CONFIG2_INSTANCE;\r
37\r
38#define IP4_CONFIG2_INSTANCE_FROM_PROTOCOL(Proto) \\r
39 CR ((Proto), \\r
40 IP4_CONFIG2_INSTANCE, \\r
41 Ip4Config2, \\r
42 IP4_CONFIG2_INSTANCE_SIGNATURE \\r
43 )\r
44\r
45#define IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE(Instance) \\r
46 CR ((Instance), \\r
47 IP4_SERVICE, \\r
48 Ip4Config2Instance, \\r
49 IP4_SERVICE_SIGNATURE \\r
50 )\r
51\r
52#define IP4_CONFIG2_INSTANCE_FROM_FORM_CALLBACK(Callback) \\r
53 CR ((Callback), \\r
54 IP4_CONFIG2_INSTANCE, \\r
55 CallbackInfo, \\r
56 IP4_CONFIG2_INSTANCE_SIGNATURE \\r
57 )\r
58\r
59#define IP4_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS(ConfigAccess) \\r
60 CR ((ConfigAccess), \\r
61 IP4_FORM_CALLBACK_INFO, \\r
62 HiiConfigAccessProtocol, \\r
63 IP4_FORM_CALLBACK_INFO_SIGNATURE \\r
64 )\r
65\r
66/**\r
67 The prototype of work function for EfiIp4Config2SetData().\r
68\r
69 @param[in] Instance The pointer to the IP4 config2 instance data.\r
70 @param[in] DataSize In bytes, the size of the buffer pointed to by Data.\r
71 @param[in] Data The data buffer to set.\r
72\r
73 @retval EFI_BAD_BUFFER_SIZE The DataSize does not match the size of the type,\r
74 8 bytes.\r
75 @retval EFI_SUCCESS The specified configuration data for the EFI IPv4\r
76 network stack was set successfully.\r
77 \r
78**/\r
79typedef\r
80EFI_STATUS\r
81(*IP4_CONFIG2_SET_DATA) (\r
82 IN IP4_CONFIG2_INSTANCE *Instance,\r
83 IN UINTN DataSize,\r
84 IN VOID *Data\r
85 );\r
86\r
87/**\r
88 The prototype of work function for EfiIp4Config2GetData().\r
89\r
90 @param[in] Instance The pointer to the IP4 config2 instance data.\r
91 @param[in, out] DataSize On input, in bytes, the size of Data. On output, in\r
92 bytes, the size of buffer required to store the specified\r
93 configuration data.\r
94 @param[in] Data The data buffer in which the configuration data is returned. \r
95 Ignored if DataSize is ZERO.\r
96\r
97 @retval EFI_BUFFER_TOO_SMALL The size of Data is too small for the specified\r
98 configuration data, and the required size is \r
99 returned in DataSize.\r
100 @retval EFI_SUCCESS The specified configuration data was obtained successfully. \r
101 \r
102**/\r
103typedef\r
104EFI_STATUS\r
105(*IP4_CONFIG2_GET_DATA) (\r
106 IN IP4_CONFIG2_INSTANCE *Instance,\r
107 IN OUT UINTN *DataSize,\r
108 IN VOID *Data OPTIONAL\r
109 );\r
110\r
111typedef union {\r
112 VOID *Ptr;\r
113 EFI_IP4_CONFIG2_INTERFACE_INFO *IfInfo;\r
114 EFI_IP4_CONFIG2_POLICY *Policy;\r
115 EFI_IP4_CONFIG2_MANUAL_ADDRESS *ManualAddress;\r
116 EFI_IPv4_ADDRESS *Gateway;\r
117 EFI_IPv4_ADDRESS *DnsServers;\r
118} IP4_CONFIG2_DATA;\r
119\r
120typedef struct {\r
121 IP4_CONFIG2_SET_DATA SetData;\r
122 IP4_CONFIG2_GET_DATA GetData;\r
123 EFI_STATUS Status;\r
124 UINT8 Attribute;\r
125 NET_MAP EventMap;\r
126 IP4_CONFIG2_DATA Data;\r
127 UINTN DataSize;\r
128} IP4_CONFIG2_DATA_ITEM;\r
129\r
130typedef struct {\r
131 UINT16 Offset;\r
132 UINT32 DataSize;\r
133 EFI_IP4_CONFIG2_DATA_TYPE DataType;\r
134} IP4_CONFIG2_DATA_RECORD;\r
135\r
136#pragma pack(1)\r
137\r
138//\r
139// heap data that contains the data for each data record.\r
140//\r
141// EFI_IP4_CONFIG2_POLICY Policy;\r
142// UINT32 ManualaddressCount;\r
143// UINT32 GatewayCount;\r
144// UINT32 DnsServersCount;\r
145// EFI_IP4_CONFIG2_MANUAL_ADDRESS ManualAddress[];\r
146// EFI_IPv4_ADDRESS Gateway[];\r
147// EFI_IPv4_ADDRESS DnsServers[];\r
148//\r
149typedef struct {\r
150 UINT16 Checksum;\r
151 UINT16 DataRecordCount;\r
152 IP4_CONFIG2_DATA_RECORD DataRecord[1];\r
153} IP4_CONFIG2_VARIABLE;\r
154\r
155#pragma pack()\r
156\r
157typedef struct {\r
158 EFI_IP4_CONFIG2_POLICY Policy; ///< manual or automatic \r
159 EFI_IP4_CONFIG2_MANUAL_ADDRESS *ManualAddress; ///< IP addresses\r
160 UINT32 ManualAddressCount; ///< IP addresses count\r
161 EFI_IPv4_ADDRESS *GatewayAddress; ///< Gateway address\r
162 UINT32 GatewayAddressCount; ///< Gateway address count\r
163 EFI_IPv4_ADDRESS *DnsAddress; ///< DNS server address\r
164 UINT32 DnsAddressCount; ///< DNS server address count\r
165} IP4_CONFIG2_NVDATA;\r
166\r
167typedef struct _IP4_FORM_CALLBACK_INFO {\r
168 UINT32 Signature;\r
169 EFI_HANDLE ChildHandle;\r
170 EFI_HII_CONFIG_ACCESS_PROTOCOL HiiConfigAccessProtocol;\r
171 EFI_DEVICE_PATH_PROTOCOL *HiiVendorDevicePath;\r
172 EFI_HII_HANDLE RegisteredHandle;\r
173} IP4_FORM_CALLBACK_INFO;\r
174\r
175struct _IP4_CONFIG2_INSTANCE {\r
176 UINT32 Signature;\r
177 BOOLEAN Configured;\r
178 LIST_ENTRY Link;\r
179 UINT16 IfIndex;\r
180\r
181 EFI_IP4_CONFIG2_PROTOCOL Ip4Config2;\r
182\r
183 EFI_IP4_CONFIG2_INTERFACE_INFO InterfaceInfo;\r
184 EFI_IP4_CONFIG2_POLICY Policy; \r
185 IP4_CONFIG2_DATA_ITEM DataItem[Ip4Config2DataTypeMaximum];\r
186\r
187 EFI_EVENT Dhcp4SbNotifyEvent;\r
188 VOID *Registration;\r
189 EFI_HANDLE Dhcp4Handle;\r
190 EFI_DHCP4_PROTOCOL *Dhcp4;\r
191 BOOLEAN DhcpSuccess;\r
192 BOOLEAN OtherInfoOnly;\r
193 EFI_EVENT Dhcp4Event;\r
194 UINT32 FailedIaAddressCount;\r
195 EFI_IPv4_ADDRESS *DeclineAddress;\r
196 UINT32 DeclineAddressCount;\r
197 \r
198 IP4_FORM_CALLBACK_INFO CallbackInfo;\r
199\r
200 IP4_CONFIG2_NVDATA Ip4NvData;\r
201};\r
202\r
203//\r
204// Configure the DHCP to request the routers and netmask\r
205// from server. The DHCP_TAG_NETMASK is included in Head.\r
206//\r
207#pragma pack(1)\r
208typedef struct {\r
209 EFI_DHCP4_PACKET_OPTION Head;\r
210 UINT8 Route;\r
9feefde0 211 UINT8 Dns;\r
1f6729ff 212} IP4_CONFIG2_DHCP4_OPTION;\r
213#pragma pack()\r
214\r
7648748e
JW
215/**\r
216 Read the configuration data from variable storage according to the VarName and\r
217 gEfiIp4Config2ProtocolGuid. It checks the integrity of variable data. If the\r
218 data is corrupted, it clears the variable data to ZERO. Othewise, it outputs the\r
219 configuration data to IP4_CONFIG2_INSTANCE.\r
220\r
221 @param[in] VarName The pointer to the variable name\r
222 @param[in, out] Instance The pointer to the IP4 config2 instance data.\r
223\r
224 @retval EFI_NOT_FOUND The variable can not be found or already corrupted.\r
225 @retval EFI_OUT_OF_RESOURCES Fail to allocate resource to complete the operation.\r
226 @retval EFI_SUCCESS The configuration data was retrieved successfully.\r
227\r
228**/\r
229EFI_STATUS\r
230Ip4Config2ReadConfigData (\r
231 IN CHAR16 *VarName,\r
232 IN OUT IP4_CONFIG2_INSTANCE *Instance\r
233 );\r
234\r
3d0a49ad
JW
235/**\r
236 Start the DHCP configuration for this IP service instance.\r
237 It will locates the EFI_IP4_CONFIG2_PROTOCOL, then start the\r
238 DHCP configuration.\r
239\r
240 @param[in] Instance The IP4 config2 instance to configure.\r
241\r
242 @retval EFI_SUCCESS The auto configuration is successfull started.\r
243 @retval Others Failed to start auto configuration.\r
244\r
245**/\r
246EFI_STATUS\r
247Ip4StartAutoConfig (\r
248 IN IP4_CONFIG2_INSTANCE *Instance\r
249 );\r
250\r
1f6729ff 251/**\r
252 Initialize an IP4_CONFIG2_INSTANCE.\r
253\r
254 @param[out] Instance The buffer of IP4_CONFIG2_INSTANCE to be initialized.\r
255\r
256 @retval EFI_OUT_OF_RESOURCES Failed to allocate resources to complete the operation.\r
257 @retval EFI_SUCCESS The IP4_CONFIG2_INSTANCE initialized successfully.\r
258\r
259**/\r
260EFI_STATUS\r
261Ip4Config2InitInstance (\r
262 OUT IP4_CONFIG2_INSTANCE *Instance\r
263 );\r
264\r
265/**\r
266 Release an IP4_CONFIG2_INSTANCE.\r
267\r
268 @param[in, out] Instance The buffer of IP4_CONFIG2_INSTANCE to be freed.\r
269\r
270**/\r
271VOID\r
272Ip4Config2CleanInstance (\r
273 IN OUT IP4_CONFIG2_INSTANCE *Instance\r
274 );\r
275\r
7648748e
JW
276/**\r
277 Request Ip4AutoReconfigCallBackDpc as a DPC at TPL_CALLBACK.\r
278\r
279 @param Event The event that is signalled.\r
280 @param Context The IP4 service binding instance.\r
281\r
282**/\r
283VOID\r
284EFIAPI\r
285Ip4AutoReconfigCallBack (\r
286 IN EFI_EVENT Event,\r
287 IN VOID *Context\r
288 );\r
289\r
1f6729ff 290/**\r
291 Destroy the Dhcp4 child in IP4_CONFIG2_INSTANCE and release the resources.\r
292\r
293 @param[in, out] Instance The buffer of IP4 config2 instance to be freed.\r
294\r
295 @retval EFI_SUCCESS The child was successfully destroyed.\r
296 @retval Others Failed to destroy the child.\r
297\r
298**/\r
299EFI_STATUS\r
300Ip4Config2DestroyDhcp4 (\r
301 IN OUT IP4_CONFIG2_INSTANCE *Instance\r
302 );\r
303\r
304#endif\r