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