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